]> granicus.if.org Git - php/commitdiff
Minor optimization (2-3%) from Brian Shire
authorIlia Alshanetsky <iliaa@php.net>
Mon, 11 Dec 2006 15:16:07 +0000 (15:16 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Mon, 11 Dec 2006 15:16:07 +0000 (15:16 +0000)
Zend/zend_operators.c
Zend/zend_operators.h

index d8853ebb7aad424a6252befa2be0edb186965c46..a51b33b5c71349f1a7605b78e693db8fcd802959 100644 (file)
@@ -304,13 +304,13 @@ ZEND_API void convert_scalar_to_number(zval *op TSRMLS_DC)
                }                                                                                                                                                                       \
        }
 
-
 ZEND_API void convert_to_long(zval *op)
 {
-       convert_to_long_base(op, 10);
+       if ((op)->type != IS_BOOL && (op)->type != IS_LONG) {
+               convert_to_long_base(op, 10);
+       }
 }
 
-
 ZEND_API void convert_to_long_base(zval *op, int base)
 {
        char *strval;
@@ -1175,11 +1175,14 @@ ZEND_API int add_string_to_string(zval *result, zval *op1, zval *op2)
 ZEND_API int concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
 {
        zval op1_copy, op2_copy;
-       int use_copy1, use_copy2;
-
+       int use_copy1 = 0, use_copy2 = 0;
 
-       zend_make_printable_zval(op1, &op1_copy, &use_copy1);
-       zend_make_printable_zval(op2, &op2_copy, &use_copy2);
+       if (op1->type != IS_STRING) {
+               zend_make_printable_zval(op1, &op1_copy, &use_copy1);
+       }
+       if (op2->type != IS_STRING) {
+               zend_make_printable_zval(op2, &op2_copy, &use_copy2);
+       }
 
        if (use_copy1) {
                /* We have created a converted copy of op1. Therefore, op1 won't become the result so
index 5763179971b745c115e46861f2fac3ead2bcdb3f..e643ccdc598c78b148bcc2925d7c74aa76fca363 100644 (file)
@@ -200,7 +200,7 @@ ZEND_API void multi_convert_to_double_ex(int argc, ...);
 ZEND_API void multi_convert_to_string_ex(int argc, ...);
 ZEND_API int add_char_to_string(zval *result, zval *op1, zval *op2);
 ZEND_API int add_string_to_string(zval *result, zval *op1, zval *op2);
-#define convert_to_string(op)                  _convert_to_string((op) ZEND_FILE_LINE_CC)
+#define convert_to_string(op) if ((op)->type != IS_STRING) { _convert_to_string((op) ZEND_FILE_LINE_CC); }
 
 ZEND_API double zend_string_to_double(const char *number, zend_uint length);