summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-12-26 16:35:12 +0300
committerAndrei Karas <akaras@inbox.ru>2014-12-31 23:07:45 +0300
commitf70d54001cd1b975db6f4668a6d54dbae7a8ac92 (patch)
tree9025875d74dda4dfb6766c555aba04700d8d0423 /src
parent0a9cee0a94185f9fabd8fd615139836a64d369f2 (diff)
downloadhercules-f70d54001cd1b975db6f4668a6d54dbae7a8ac92.tar.gz
hercules-f70d54001cd1b975db6f4668a6d54dbae7a8ac92.tar.bz2
hercules-f70d54001cd1b975db6f4668a6d54dbae7a8ac92.tar.xz
hercules-f70d54001cd1b975db6f4668a6d54dbae7a8ac92.zip
Improve performance a bit by removing strlen(str) > 0.
Diffstat (limited to 'src')
-rw-r--r--src/common/sysinfo.c2
-rw-r--r--src/login/login.c6
-rw-r--r--src/map/atcommand.c3
-rw-r--r--src/map/irc-bot.c3
-rw-r--r--src/map/log.c2
-rw-r--r--src/map/map.c2
6 files changed, 10 insertions, 8 deletions
diff --git a/src/common/sysinfo.c b/src/common/sysinfo.c
index 605256100..ee8ff504a 100644
--- a/src/common/sysinfo.c
+++ b/src/common/sysinfo.c
@@ -594,7 +594,7 @@ void sysinfo_osversion_retrieve(void) {
// Include service pack (if any) and build number.
- if (strlen(osvi.szCSDVersion) > 0) {
+ if (osvi.szCSDVersion[0] != '\0') {
StrBuf->Printf(&buf, " %s", osvi.szCSDVersion);
}
diff --git a/src/login/login.c b/src/login/login.c
index c006d9c45..e5f565644 100644
--- a/src/login/login.c
+++ b/src/login/login.c
@@ -409,7 +409,7 @@ void login_fromchar_account(int fd, int account_id, struct mmo_account *acc)
char_slots = acc->char_slots;
safestrncpy(pincode, acc->pincode, sizeof(pincode));
safestrncpy(birthdate, acc->birthdate, sizeof(birthdate));
- if( strlen(pincode) == 0 )
+ if (pincode[0] == '\0')
memset(pincode,'\0',sizeof(pincode));
safestrncpy((char*)WFIFOP(fd,6), email, 40);
@@ -1097,9 +1097,9 @@ int login_mmo_auth(struct login_session_data* sd, bool isServer) {
// Account creation with _M/_F
if( login_config.new_account_flag ) {
- if( len > 2 && strnlen(sd->passwd, NAME_LENGTH) > 0 && // valid user and password lengths
+ if (len > 2 && sd->passwd[0] != '\0' && // valid user and password lengths
sd->passwdenc == 0 && // unencoded password
- sd->userid[len-2] == '_' && memchr("FfMm", sd->userid[len-1], 4) ) // _M/_F suffix
+ sd->userid[len-2] == '_' && memchr("FfMm", sd->userid[len-1], 4)) // _M/_F suffix
{
int result;
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index d43637b81..6f97141b2 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -8740,10 +8740,11 @@ ACMD(channel) {
if (strcmpi(subcmd,"create") == 0 && (clif->hChSys->allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN))) {
// sub1 = channel name; sub2 = password; sub3 = unused
+ size_t len = strlen(sub1);
if (sub1[0] != '#') {
clif->message(fd, msg_txt(1405));// Channel name must start with a '#'
return false;
- } else if (strlen(sub1) < 3 || strlen(sub1) > HCHSYS_NAME_LENGTH) {
+ } else if (len < 3 || len > HCHSYS_NAME_LENGTH) {
sprintf(atcmd_output, msg_txt(1406), HCHSYS_NAME_LENGTH);// Channel length must be between 3 and %d
clif->message(fd, atcmd_output);
return false;
diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c
index 8b4991c20..bd35a9867 100644
--- a/src/map/irc-bot.c
+++ b/src/map/irc-bot.c
@@ -281,7 +281,8 @@ void irc_privmsg_ctcp(int fd, char *cmd, char *source, char *target, char *msg)
* @see irc_parse_sub
*/
void irc_privmsg(int fd, char *cmd, char *source, char *target, char *msg) {
- if( msg && *msg == '\001' && strlen(msg) > 2 && msg[strlen(msg)-1] == '\001' ) {
+ size_t len = msg ? strlen(msg) : 0;
+ if (msg && *msg == '\001' && len > 2 && msg[len - 1] == '\001') {
// CTCP
char command[IRC_MESSAGE_LENGTH], message[IRC_MESSAGE_LENGTH];
command[0] = message[0] = '\0';
diff --git a/src/map/log.c b/src/map/log.c
index 9dcf1f359..f18efbfb7 100644
--- a/src/map/log.c
+++ b/src/map/log.c
@@ -368,7 +368,7 @@ void log_sql_init(void) {
exit(EXIT_FAILURE);
ShowStatus(""CL_WHITE"[SQL]"CL_RESET": Successfully '"CL_GREEN"connected"CL_RESET"' to Database '"CL_WHITE"%s"CL_RESET"'.\n", logs->db_name);
- if( strlen(map->default_codepage) > 0 )
+ if (map->default_codepage[0] != '\0')
if ( SQL_ERROR == SQL->SetEncoding(logs->mysql_handle, map->default_codepage) )
Sql_ShowDebug(logs->mysql_handle);
}
diff --git a/src/map/map.c b/src/map/map.c
index 173835d0d..2bebd3c55 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -3810,7 +3810,7 @@ int map_sql_init(void)
exit(EXIT_FAILURE);
ShowStatus("connect success! (Map Server Connection)\n");
- if( strlen(map->default_codepage) > 0 )
+ if (map->default_codepage[0] != '\0')
if ( SQL_ERROR == SQL->SetEncoding(map->mysql_handle, map->default_codepage) )
Sql_ShowDebug(map->mysql_handle);