com php-src: avoid strlen in common case: Zend/zend_compile .c

[email protected] (Anatol Belski)
Newsgroups php.cvs
Message-ID <[email protected]>
Commit:    d5bc862470b0635d51967b82c9324efcd69286c8
Author:    Anatol Belski <[email protected]>         Tue, 16 May 2017 12:49:19 +0200
Parents:   ea35965568f5bd5688524a66f1a33b84ac0f6253
Branches:  master

Link:       http://git.php.net/?p=php-src.git;a=commitdiff;h=d5bc862470b0635d51967b82c9324efcd69286c8

Log:
avoid strlen in common case

Changed paths:
  M  Zend/zend_compile.c


Diff:
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 5485a1c..82da49a 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -6503,9 +6503,9 @@ static zend_bool zend_try_ct_eval_magic_const(zval *zv, zend_ast *ast) /* {{{ */
 			zend_string *filename = CG(compiled_filename);
 			zend_string *dirname = zend_string_init(ZSTR_VAL(filename), ZSTR_LEN(filename), 0);
 #ifdef ZEND_WIN32
-			php_win32_ioutil_dirname(ZSTR_VAL(dirname), ZSTR_LEN(dirname));
+			ZSTR_LEN(dirname) = php_win32_ioutil_dirname(ZSTR_VAL(dirname), ZSTR_LEN(dirname));
 #else
-			zend_dirname(ZSTR_VAL(dirname), ZSTR_LEN(dirname));
+			ZSTR_LEN(dirname) = zend_dirname(ZSTR_VAL(dirname), ZSTR_LEN(dirname));
 #endif
 
 			if (strcmp(ZSTR_VAL(dirname), ".") == 0) {
@@ -6515,9 +6515,9 @@ static zend_bool zend_try_ct_eval_magic_const(zval *zv, zend_ast *ast) /* {{{ */
 #elif HAVE_GETWD
 				ZEND_IGNORE_VALUE(VCWD_GETWD(ZSTR_VAL(dirname)));
 #endif
+				ZSTR_LEN(dirname) = strlen(ZSTR_VAL(dirname));
 			}
 
-			ZSTR_LEN(dirname) = strlen(ZSTR_VAL(dirname));
 			ZVAL_STR(zv, dirname);
 			break;
 		}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.