]> granicus.if.org Git - php/commitdiff
Save one type checking if the type is already string
authorXinchen Hui <laruence@php.net>
Tue, 13 May 2014 06:05:28 +0000 (14:05 +0800)
committerXinchen Hui <laruence@php.net>
Tue, 13 May 2014 06:05:28 +0000 (14:05 +0800)
Zend/zend_API.c
Zend/zend_builtin_functions.c

index 6ef4c0b4674ce9b4047b935b5df59e4ec7fea3da..f1e9614a220baa9b633d39f4861a3eb088d72133 100644 (file)
@@ -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
index bc998abc3c5b3de68b596266e5da82113bfb0279..d8b828763fe29f54908cdb7b9d8164c7ea1ff0de 100644 (file)
@@ -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);
 }
 /* }}} */