Re: com php-src: avoid multiple strlen() calls for the same: main/fopen_wrappers.c

From: Date: Sun, 14 Sep 2014 22:30:34 +0000
Subject: Re: com php-src: avoid multiple strlen() calls for the same: main/fopen_wrappers.c
References: 1  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-81604@lists.php.net to get a copy of this message
Hi Anatol 2014-09-13 23:21 GMT+02:00 Anatol Belski <ab@php.net>: > Commit: 586b863ba754a19495f4abaadd32df85a394616d > Author: Anatol Belski <ab@php.net> Sat, 13 Sep 2014 17:58:47 +0200 > Parents: 47fb7a46ac1ff29b065fd5e46b0c3174e7e2b2a0 > Branches: master > > Link: > http://git.php.net/?p=php-src.git;a=commitdiff;h=586b863ba754a19495f4abaadd32df85a394616d > > Log: > avoid multiple strlen() calls for the same If we are micro optimizing like this, wouldn't this patch make more sense after your changes: --- a/main/fopen_wrappers.c +++ b/main/fopen_wrappers.c @@ -759,11 +759,15 @@ PHPAPI char *expand_filepath_with_mode(const char *filepath, char *real_path, co cwd_state new_state; char cwd[MAXPATHLEN]; int copy_len; - int path_len = (int)strlen(filepath); + int path_len; if (!filepath[0]) { return NULL; - } else if (IS_ABSOLUTE_PATH(filepath, path_len)) { + } + + path_len = (int) strlen(filepath); + + if (IS_ABSOLUTE_PATH(filepath, path_len)) { cwd[0] = '\0'; } else { const char *iam = SG(request_info).path_translated; -- regards, Kalle Sommer Nielsen kalle@php.net

« previous php.cvs (#81604) next »