]> granicus.if.org Git - php/commitdiff
Avoid duplication
authorDmitry Stogov <dmitry@zend.com>
Wed, 26 Aug 2015 11:53:41 +0000 (14:53 +0300)
committerDmitry Stogov <dmitry@zend.com>
Wed, 26 Aug 2015 11:53:41 +0000 (14:53 +0300)
ext/standard/array.c
ext/standard/type.c

index b6684c8dca513d2d2112e81238ae8fa26a514c27..642cc29eba32d5ef3863131f608bb6ec328d064b 100644 (file)
@@ -1520,7 +1520,7 @@ static void php_compact_var(HashTable *eg_active_symbol_table, zval *return_valu
        ZVAL_DEREF(entry);
        if (Z_TYPE_P(entry) == IS_STRING) {
                if ((value_ptr = zend_hash_find_ind(eg_active_symbol_table, Z_STR_P(entry))) != NULL) {
-                       ZVAL_DUP(&data, value_ptr);
+                       ZVAL_COPY(&data, value_ptr);
                        zend_hash_update(Z_ARRVAL_P(return_value), Z_STR_P(entry), &data);
                }
        } else if (Z_TYPE_P(entry) == IS_ARRAY) {
@@ -3292,12 +3292,14 @@ PHP_FUNCTION(array_unique)
 
        php_set_compare_func(sort_type);
 
-       RETVAL_ARR(zend_array_dup(Z_ARRVAL_P(array)));
 
        if (Z_ARRVAL_P(array)->nNumOfElements <= 1) {   /* nothing to do */
+               ZVAL_COPY(return_value, array);
                return;
        }
 
+       RETVAL_ARR(zend_array_dup(Z_ARRVAL_P(array)));
+
        /* create and sort array with pointers to the target_hash buckets */
        arTmp = (struct bucketindex *) pemalloc((Z_ARRVAL_P(array)->nNumOfElements + 1) * sizeof(struct bucketindex), Z_ARRVAL_P(array)->u.flags & HASH_FLAG_PERSISTENT);
        if (!arTmp) {
index b4d8586dccda0fae640e7aeaea470c31b911097c..ea88d41a23c6db428ab2831ff3ec1ce12328de9a 100644 (file)
@@ -154,8 +154,11 @@ PHP_FUNCTION(intval)
        ZEND_PARSE_PARAMETERS_END();
 #endif
 
-       ZVAL_DUP(return_value, num);
-       convert_to_long_base(return_value, (int)base);
+       if (Z_TYPE_P(num) != IS_STRING) {
+               RETVAL_LONG(zval_get_long(num));
+       } else {
+               RETVAL_LONG(ZEND_STRTOL(Z_STRVAL_P(num), NULL, base));
+       }
 }
 /* }}} */