Replace instances of Q_strcmp with strcmp for speed

This commit is contained in:
cypress 2023-07-22 12:18:27 -04:00
parent 8a4bdbabe1
commit 69c8fa7727
14 changed files with 24 additions and 40 deletions

View File

@ -546,7 +546,7 @@ void Cmd_AddCommand (char *cmd_name, xcommand_t function)
// fail if the command already exists
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
{
if (!Q_strcmp (cmd_name, cmd->name))
if (!strcmp (cmd_name, cmd->name))
{
Con_Printf ("Cmd_AddCommand: %s already defined\n", cmd_name);
return;
@ -571,7 +571,7 @@ qboolean Cmd_Exists (char *cmd_name)
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
{
if (!Q_strcmp (cmd_name,cmd->name))
if (!strcmp (cmd_name,cmd->name))
return true;
}

View File

@ -250,21 +250,6 @@ void Q_strcat (char *dest, char *src)
Q_strcpy (dest, src);
}
int Q_strcmp (char *s1, char *s2)
{
while (1)
{
if (*s1 != *s2)
return -1; // strings not equal
if (!*s1)
return 0; // strings are equal
s1++;
s2++;
}
return -1;
}
int Q_strncmp (char *s1, char *s2, int count)
{
while (1)
@ -1008,7 +993,7 @@ int COM_CheckParm (char *parm)
{
if (!com_argv[i])
continue; // NEXTSTEP sometimes clears appkit vars.
if (!Q_strcmp (parm,com_argv[i]))
if (!strcmp (parm,com_argv[i]))
return i;
}
@ -1054,7 +1039,7 @@ void COM_InitArgv (int argc, char **argv)
com_argc++)
{
largv[com_argc] = argv[com_argc];
if (!Q_strcmp ("-safe", argv[com_argc]))
if (!strcmp ("-safe", argv[com_argc]))
safe = true;
}

View File

@ -150,7 +150,6 @@ void Q_strncpy (char *dest, char *src, int count);
int Q_strlen (char *str);
char *Q_strrchr (char *s, char c);
void Q_strcat (char *dest, char *src);
int Q_strcmp (char *s1, char *s2);
int Q_strncmp (char *s1, char *s2, int count);
int Q_strcasecmp (char *s1, char *s2);
int Q_strncasecmp (char *s1, char *s2, int n);

View File

@ -34,7 +34,7 @@ cvar_t *Cvar_FindVar (char *var_name)
cvar_t *var;
for (var=cvar_vars ; var ; var=var->next)
if (!Q_strcmp (var_name, var->name))
if (!strcmp (var_name, var->name))
return var;
return NULL;
@ -113,7 +113,7 @@ void Cvar_Set (char *var_name, char *value)
return;
}
changed = Q_strcmp(var->string, value);
changed = strcmp(var->string, value);
Z_Free (var->string); // free the old value string

View File

@ -912,7 +912,7 @@ void Host_Name_f (void)
if (cmd_source == src_command)
{
if (Q_strcmp(cl_name.string, newName) == 0)
if (strcmp(cl_name.string, newName) == 0)
return;
Cvar_Set ("_cl_name", newName);
if (cls.state == ca_connected)
@ -921,7 +921,7 @@ void Host_Name_f (void)
}
if (host_client->name[0] && strcmp(host_client->name, "unconnected") )
if (Q_strcmp(host_client->name, newName) != 0)
if (strcmp(host_client->name, newName) != 0)
Con_Printf ("%s renamed to %s\n", host_client->name, newName);
Q_strcpy (host_client->name, newName);
host_client->edict->v.netname = host_client->name - pr_strings;
@ -949,7 +949,7 @@ void Host_Please_f (void)
if (cmd_source != src_command)
return;
if ((Cmd_Argc () == 3) && Q_strcmp(Cmd_Argv(1), "#") == 0)
if ((Cmd_Argc () == 3) && strcmp(Cmd_Argv(1), "#") == 0)
{
j = Q_atof(Cmd_Argv(2)) - 1;
if (j < 0 || j >= svs.maxclients)
@ -1423,7 +1423,7 @@ void Host_Kick_f (void)
save = host_client;
if (Cmd_Argc() > 2 && Q_strcmp(Cmd_Argv(1), "#") == 0)
if (Cmd_Argc() > 2 && strcmp(Cmd_Argv(1), "#") == 0)
{
i = Q_atof(Cmd_Argv(2)) - 1;
if (i < 0 || i >= svs.maxclients)

View File

@ -488,7 +488,7 @@ void NET_Stats_f (void)
Con_Printf("shortPacketCount = %i\n", shortPacketCount);
Con_Printf("droppedDatagrams = %i\n", droppedDatagrams);
}
else if (Q_strcmp(Cmd_Argv(1), "*") == 0)
else if (strcmp(Cmd_Argv(1), "*") == 0)
{
for (s = net_activeSockets; s; s = s->next)
PrintStats(s);
@ -864,7 +864,7 @@ static qsocket_t *_Datagram_CheckNewConnections (void)
command = MSG_ReadByte();
if (command == CCREQ_SERVER_INFO)
{
if (Q_strcmp(MSG_ReadString(), "QUAKE") != 0)
if (strcmp(MSG_ReadString(), "QUAKE") != 0)
return NULL;
SZ_Clear(&net_message);
@ -968,7 +968,7 @@ static qsocket_t *_Datagram_CheckNewConnections (void)
if (command != CCREQ_CONNECT)
return NULL;
if (Q_strcmp(MSG_ReadString(), "QUAKE") != 0)
if (strcmp(MSG_ReadString(), "QUAKE") != 0)
return NULL;
if (MSG_ReadByte() != NET_PROTOCOL_VERSION)

View File

@ -50,7 +50,7 @@ void Loop_SearchForHosts (qboolean xmit)
return;
hostCacheCount = 1;
if (Q_strcmp(hostname.string, "UNNAMED") == 0)
if (strcmp(hostname.string, "UNNAMED") == 0)
Q_strcpy(hostcache[0].name, "local");
else
Q_strcpy(hostcache[0].name, hostname.string);
@ -64,7 +64,7 @@ void Loop_SearchForHosts (qboolean xmit)
qsocket_t *Loop_Connect (char *host)
{
if (Q_strcmp(host,"local") != 0)
if (strcmp(host,"local") != 0)
return NULL;
localconnectpending = true;

View File

@ -77,7 +77,7 @@ int MPATH_Init (void)
myAddr = *(int *)local->h_addr_list[0];
// if the quake hostname isn't set, set it to the machine name
if (Q_strcmp(hostname.string, "UNNAMED") == 0)
if (strcmp(hostname.string, "UNNAMED") == 0)
{
// see if it's a text IP address (well, close enough)
for (p = buff; *p; p++)

View File

@ -736,7 +736,7 @@ void Serial_SearchForHosts (qboolean xmit)
// see if we've already answered
for (n = 0; n < hostCacheCount; n++)
if (Q_strcmp (hostcache[n].cname, "#") == 0)
if (strcmp (hostcache[n].cname, "#") == 0)
return;
for (n = 0; n < NUM_COM_PORTS; n++)
@ -901,7 +901,7 @@ static qsocket_t *_Serial_CheckNewConnections (SerialLine *p)
if (command == CCREQ_SERVER_INFO)
{
if (Q_strcmp(MSG_ReadString(), "QUAKE") != 0)
if (strcmp(MSG_ReadString(), "QUAKE") != 0)
return NULL;
if (MSG_ReadByte() != SERIAL_PROTOCOL_VERSION)
@ -921,7 +921,7 @@ static qsocket_t *_Serial_CheckNewConnections (SerialLine *p)
if (command != CCREQ_CONNECT)
return NULL;
if (Q_strcmp(MSG_ReadString(), "QUAKE") != 0)
if (strcmp(MSG_ReadString(), "QUAKE") != 0)
return NULL;
// send him back the info about the server connection he has been allocated

View File

@ -69,7 +69,7 @@ int UDP_Init (void)
myAddr = *(int *)local->h_addr_list[0];
// if the quake hostname isn't set, set it to the machine name
if (Q_strcmp(hostname.string, "UNNAMED") == 0)
if (strcmp(hostname.string, "UNNAMED") == 0)
{
buff[15] = 0;
Cvar_Set ("hostname", buff);

View File

@ -97,7 +97,7 @@ int UDP_Init (void)
myAddr = gethostid();
// if the quake hostname isn't set, set it to the machine name
if (Q_strcmp(hostname.string, "UNNAMED") == 0)
if (strcmp(hostname.string, "UNNAMED") == 0)
{
Cvar_Set ("hostname", "3ds");
}

View File

@ -187,7 +187,7 @@ int WINS_Init (void)
}
// if the quake hostname isn't set, set it to the machine name
if (Q_strcmp(hostname.string, "UNNAMED") == 0)
if (strcmp(hostname.string, "UNNAMED") == 0)
{
// see if it's a text IP address (well, close enough)
for (p = buff; *p; p++)

View File

@ -78,7 +78,7 @@ int WIPX_Init (void)
if (pgethostname(buff, MAXHOSTNAMELEN) == 0)
{
// if the quake hostname isn't set, set it to the machine name
if (Q_strcmp(hostname.string, "UNNAMED") == 0)
if (strcmp(hostname.string, "UNNAMED") == 0)
{
// see if it's a text IP address (well, close enough)
for (p = buff; *p; p++)

View File

@ -287,7 +287,7 @@ sfx_t *S_FindName (char *name)
// see if already loaded
for (i=0 ; i < num_sfx ; i++)
if (!Q_strcmp(known_sfx[i].name, name))
if (!strcmp(known_sfx[i].name, name))
{
return &known_sfx[i];
}