Skip to content

Commit 766c721

Browse files
committed
perf: save strlen to var instead of calc it each iterator
1 parent 9580d47 commit 766c721

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

sapi/fpm/fpm/fpm_conf.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,8 @@ static int fpm_conf_process_all_pools(void)
973973
return -1;
974974
}
975975

976-
for (i = 0; i < strlen(status); i++) {
976+
size_t status_len = strlen(status);
977+
for (i = 0; i < status_len; i++) {
977978
if (!isalnum(status[i]) && status[i] != '/' && status[i] != '-' && status[i] != '_' && status[i] != '.' && status[i] != '~') {
978979
zlog(ZLOG_ERROR, "[pool %s] the status path '%s' must contain only the following characters '[alphanum]/_-.~'", wp->config->name, status);
979980
return -1;
@@ -991,12 +992,13 @@ static int fpm_conf_process_all_pools(void)
991992
return -1;
992993
}
993994

994-
if (strlen(ping) < 2) {
995+
size_t ping_len = strlen(ping);
996+
if (ping_len < 2) {
995997
zlog(ZLOG_ERROR, "[pool %s] the ping path '%s' is not long enough", wp->config->name, ping);
996998
return -1;
997999
}
9981000

999-
for (i = 0; i < strlen(ping); i++) {
1001+
for (i = 0; i < ping_len; i++) {
10001002
if (!isalnum(ping[i]) && ping[i] != '/' && ping[i] != '-' && ping[i] != '_' && ping[i] != '.' && ping[i] != '~') {
10011003
zlog(ZLOG_ERROR, "[pool %s] the ping path '%s' must contain only the following characters '[alphanum]/_-.~'", wp->config->name, ping);
10021004
return -1;

0 commit comments

Comments
 (0)