From: Xinchen Hui Date: Tue, 13 May 2014 06:05:28 +0000 (+0800) Subject: Save one type checking if the type is already string X-Git-Tag: POST_PHPNG_MERGE~378^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=075a6ced0a3cd91014ab28272a120eca660e31fa;p=php Save one type checking if the type is already string --- diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 6ef4c0b467..f1e9614a22 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -480,12 +480,12 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons } /* break omitted intentionally */ - case IS_STRING: case IS_LONG: case IS_DOUBLE: case IS_FALSE: case IS_TRUE: convert_to_string_ex(arg); + case IS_STRING: if (UNEXPECTED(Z_ISREF_P(arg))) { /* it's dangerous to return pointers to string buffer of referenced variable, because it can @@ -527,12 +527,12 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons } /* break omitted intentionally */ - case IS_STRING: case IS_LONG: case IS_DOUBLE: case IS_FALSE: case IS_TRUE: convert_to_string_ex(arg); + case IS_STRING: if (UNEXPECTED(Z_ISREF_P(arg))) { /* it's dangerous to return pointers to string buffer of referenced variable, because it can diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index bc998abc3c..d8b828763f 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -405,7 +405,6 @@ ZEND_FUNCTION(func_num_args) } /* }}} */ - /* {{{ proto mixed func_get_arg(int arg_num) Get the $arg_num'th argument that was passed to the function */ ZEND_FUNCTION(func_get_arg) @@ -443,7 +442,6 @@ ZEND_FUNCTION(func_get_arg) } /* }}} */ - /* {{{ proto array func_get_args() Get an array of the arguments that were passed to the function */ ZEND_FUNCTION(func_get_args) @@ -478,19 +476,17 @@ ZEND_FUNCTION(func_get_args) } /* }}} */ - /* {{{ proto int strlen(string str) Get string length */ ZEND_FUNCTION(strlen) { - char *s1; - int s1_len; + zend_string *s; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &s1, &s1_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &s) == FAILURE) { return; } - RETVAL_LONG(s1_len); + RETVAL_LONG(s->len); } /* }}} */