mirror of
https://github.com/nzp-team/glquake.git
synced 2024-11-10 06:31:35 +00:00
Replace instances of Q_strcmp with strcmp for speed
This commit is contained in:
parent
8a4bdbabe1
commit
69c8fa7727
14 changed files with 24 additions and 40 deletions
|
@ -546,7 +546,7 @@ void Cmd_AddCommand (char *cmd_name, xcommand_t function)
|
||||||
// fail if the command already exists
|
// fail if the command already exists
|
||||||
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
|
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);
|
Con_Printf ("Cmd_AddCommand: %s already defined\n", cmd_name);
|
||||||
return;
|
return;
|
||||||
|
@ -571,7 +571,7 @@ qboolean Cmd_Exists (char *cmd_name)
|
||||||
|
|
||||||
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
|
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
|
||||||
{
|
{
|
||||||
if (!Q_strcmp (cmd_name,cmd->name))
|
if (!strcmp (cmd_name,cmd->name))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -250,21 +250,6 @@ void Q_strcat (char *dest, char *src)
|
||||||
Q_strcpy (dest, 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)
|
int Q_strncmp (char *s1, char *s2, int count)
|
||||||
{
|
{
|
||||||
while (1)
|
while (1)
|
||||||
|
@ -1008,7 +993,7 @@ int COM_CheckParm (char *parm)
|
||||||
{
|
{
|
||||||
if (!com_argv[i])
|
if (!com_argv[i])
|
||||||
continue; // NEXTSTEP sometimes clears appkit vars.
|
continue; // NEXTSTEP sometimes clears appkit vars.
|
||||||
if (!Q_strcmp (parm,com_argv[i]))
|
if (!strcmp (parm,com_argv[i]))
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1054,7 +1039,7 @@ void COM_InitArgv (int argc, char **argv)
|
||||||
com_argc++)
|
com_argc++)
|
||||||
{
|
{
|
||||||
largv[com_argc] = argv[com_argc];
|
largv[com_argc] = argv[com_argc];
|
||||||
if (!Q_strcmp ("-safe", argv[com_argc]))
|
if (!strcmp ("-safe", argv[com_argc]))
|
||||||
safe = true;
|
safe = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,7 +150,6 @@ void Q_strncpy (char *dest, char *src, int count);
|
||||||
int Q_strlen (char *str);
|
int Q_strlen (char *str);
|
||||||
char *Q_strrchr (char *s, char c);
|
char *Q_strrchr (char *s, char c);
|
||||||
void Q_strcat (char *dest, char *src);
|
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_strncmp (char *s1, char *s2, int count);
|
||||||
int Q_strcasecmp (char *s1, char *s2);
|
int Q_strcasecmp (char *s1, char *s2);
|
||||||
int Q_strncasecmp (char *s1, char *s2, int n);
|
int Q_strncasecmp (char *s1, char *s2, int n);
|
||||||
|
|
|
@ -34,7 +34,7 @@ cvar_t *Cvar_FindVar (char *var_name)
|
||||||
cvar_t *var;
|
cvar_t *var;
|
||||||
|
|
||||||
for (var=cvar_vars ; var ; var=var->next)
|
for (var=cvar_vars ; var ; var=var->next)
|
||||||
if (!Q_strcmp (var_name, var->name))
|
if (!strcmp (var_name, var->name))
|
||||||
return var;
|
return var;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -113,7 +113,7 @@ void Cvar_Set (char *var_name, char *value)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
changed = Q_strcmp(var->string, value);
|
changed = strcmp(var->string, value);
|
||||||
|
|
||||||
Z_Free (var->string); // free the old value string
|
Z_Free (var->string); // free the old value string
|
||||||
|
|
||||||
|
|
|
@ -912,7 +912,7 @@ void Host_Name_f (void)
|
||||||
|
|
||||||
if (cmd_source == src_command)
|
if (cmd_source == src_command)
|
||||||
{
|
{
|
||||||
if (Q_strcmp(cl_name.string, newName) == 0)
|
if (strcmp(cl_name.string, newName) == 0)
|
||||||
return;
|
return;
|
||||||
Cvar_Set ("_cl_name", newName);
|
Cvar_Set ("_cl_name", newName);
|
||||||
if (cls.state == ca_connected)
|
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 (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);
|
Con_Printf ("%s renamed to %s\n", host_client->name, newName);
|
||||||
Q_strcpy (host_client->name, newName);
|
Q_strcpy (host_client->name, newName);
|
||||||
host_client->edict->v.netname = host_client->name - pr_strings;
|
host_client->edict->v.netname = host_client->name - pr_strings;
|
||||||
|
@ -949,7 +949,7 @@ void Host_Please_f (void)
|
||||||
if (cmd_source != src_command)
|
if (cmd_source != src_command)
|
||||||
return;
|
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;
|
j = Q_atof(Cmd_Argv(2)) - 1;
|
||||||
if (j < 0 || j >= svs.maxclients)
|
if (j < 0 || j >= svs.maxclients)
|
||||||
|
@ -1423,7 +1423,7 @@ void Host_Kick_f (void)
|
||||||
|
|
||||||
save = host_client;
|
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;
|
i = Q_atof(Cmd_Argv(2)) - 1;
|
||||||
if (i < 0 || i >= svs.maxclients)
|
if (i < 0 || i >= svs.maxclients)
|
||||||
|
|
|
@ -488,7 +488,7 @@ void NET_Stats_f (void)
|
||||||
Con_Printf("shortPacketCount = %i\n", shortPacketCount);
|
Con_Printf("shortPacketCount = %i\n", shortPacketCount);
|
||||||
Con_Printf("droppedDatagrams = %i\n", droppedDatagrams);
|
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)
|
for (s = net_activeSockets; s; s = s->next)
|
||||||
PrintStats(s);
|
PrintStats(s);
|
||||||
|
@ -864,7 +864,7 @@ static qsocket_t *_Datagram_CheckNewConnections (void)
|
||||||
command = MSG_ReadByte();
|
command = MSG_ReadByte();
|
||||||
if (command == CCREQ_SERVER_INFO)
|
if (command == CCREQ_SERVER_INFO)
|
||||||
{
|
{
|
||||||
if (Q_strcmp(MSG_ReadString(), "QUAKE") != 0)
|
if (strcmp(MSG_ReadString(), "QUAKE") != 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
SZ_Clear(&net_message);
|
SZ_Clear(&net_message);
|
||||||
|
@ -968,7 +968,7 @@ static qsocket_t *_Datagram_CheckNewConnections (void)
|
||||||
if (command != CCREQ_CONNECT)
|
if (command != CCREQ_CONNECT)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (Q_strcmp(MSG_ReadString(), "QUAKE") != 0)
|
if (strcmp(MSG_ReadString(), "QUAKE") != 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (MSG_ReadByte() != NET_PROTOCOL_VERSION)
|
if (MSG_ReadByte() != NET_PROTOCOL_VERSION)
|
||||||
|
|
|
@ -50,7 +50,7 @@ void Loop_SearchForHosts (qboolean xmit)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
hostCacheCount = 1;
|
hostCacheCount = 1;
|
||||||
if (Q_strcmp(hostname.string, "UNNAMED") == 0)
|
if (strcmp(hostname.string, "UNNAMED") == 0)
|
||||||
Q_strcpy(hostcache[0].name, "local");
|
Q_strcpy(hostcache[0].name, "local");
|
||||||
else
|
else
|
||||||
Q_strcpy(hostcache[0].name, hostname.string);
|
Q_strcpy(hostcache[0].name, hostname.string);
|
||||||
|
@ -64,7 +64,7 @@ void Loop_SearchForHosts (qboolean xmit)
|
||||||
|
|
||||||
qsocket_t *Loop_Connect (char *host)
|
qsocket_t *Loop_Connect (char *host)
|
||||||
{
|
{
|
||||||
if (Q_strcmp(host,"local") != 0)
|
if (strcmp(host,"local") != 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
localconnectpending = true;
|
localconnectpending = true;
|
||||||
|
|
|
@ -77,7 +77,7 @@ int MPATH_Init (void)
|
||||||
myAddr = *(int *)local->h_addr_list[0];
|
myAddr = *(int *)local->h_addr_list[0];
|
||||||
|
|
||||||
// if the quake hostname isn't set, set it to the machine name
|
// 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)
|
// see if it's a text IP address (well, close enough)
|
||||||
for (p = buff; *p; p++)
|
for (p = buff; *p; p++)
|
||||||
|
|
|
@ -736,7 +736,7 @@ void Serial_SearchForHosts (qboolean xmit)
|
||||||
|
|
||||||
// see if we've already answered
|
// see if we've already answered
|
||||||
for (n = 0; n < hostCacheCount; n++)
|
for (n = 0; n < hostCacheCount; n++)
|
||||||
if (Q_strcmp (hostcache[n].cname, "#") == 0)
|
if (strcmp (hostcache[n].cname, "#") == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (n = 0; n < NUM_COM_PORTS; n++)
|
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 (command == CCREQ_SERVER_INFO)
|
||||||
{
|
{
|
||||||
if (Q_strcmp(MSG_ReadString(), "QUAKE") != 0)
|
if (strcmp(MSG_ReadString(), "QUAKE") != 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (MSG_ReadByte() != SERIAL_PROTOCOL_VERSION)
|
if (MSG_ReadByte() != SERIAL_PROTOCOL_VERSION)
|
||||||
|
@ -921,7 +921,7 @@ static qsocket_t *_Serial_CheckNewConnections (SerialLine *p)
|
||||||
if (command != CCREQ_CONNECT)
|
if (command != CCREQ_CONNECT)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (Q_strcmp(MSG_ReadString(), "QUAKE") != 0)
|
if (strcmp(MSG_ReadString(), "QUAKE") != 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// send him back the info about the server connection he has been allocated
|
// send him back the info about the server connection he has been allocated
|
||||||
|
|
|
@ -69,7 +69,7 @@ int UDP_Init (void)
|
||||||
myAddr = *(int *)local->h_addr_list[0];
|
myAddr = *(int *)local->h_addr_list[0];
|
||||||
|
|
||||||
// if the quake hostname isn't set, set it to the machine name
|
// 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;
|
buff[15] = 0;
|
||||||
Cvar_Set ("hostname", buff);
|
Cvar_Set ("hostname", buff);
|
||||||
|
|
|
@ -97,7 +97,7 @@ int UDP_Init (void)
|
||||||
myAddr = gethostid();
|
myAddr = gethostid();
|
||||||
|
|
||||||
// if the quake hostname isn't set, set it to the machine name
|
// 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");
|
Cvar_Set ("hostname", "3ds");
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,7 +187,7 @@ int WINS_Init (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the quake hostname isn't set, set it to the machine name
|
// 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)
|
// see if it's a text IP address (well, close enough)
|
||||||
for (p = buff; *p; p++)
|
for (p = buff; *p; p++)
|
||||||
|
|
|
@ -78,7 +78,7 @@ int WIPX_Init (void)
|
||||||
if (pgethostname(buff, MAXHOSTNAMELEN) == 0)
|
if (pgethostname(buff, MAXHOSTNAMELEN) == 0)
|
||||||
{
|
{
|
||||||
// if the quake hostname isn't set, set it to the machine name
|
// 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)
|
// see if it's a text IP address (well, close enough)
|
||||||
for (p = buff; *p; p++)
|
for (p = buff; *p; p++)
|
||||||
|
|
|
@ -287,7 +287,7 @@ sfx_t *S_FindName (char *name)
|
||||||
|
|
||||||
// see if already loaded
|
// see if already loaded
|
||||||
for (i=0 ; i < num_sfx ; i++)
|
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];
|
return &known_sfx[i];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue