diff options
| author | Dmitry Stogov <dmitry@zend.com> | 2019-06-06 02:23:17 +0300 |
|---|---|---|
| committer | Dmitry Stogov <dmitry@zend.com> | 2019-06-06 02:23:17 +0300 |
| commit | e029cc4dd45c4ee5ab6678d6c732df9ed17b06d0 (patch) | |
| tree | 20c4ac0d20f4f996c9436b40316048de1c106a44 /Zend/zend_operators.c | |
| parent | b4d21310cb965e50b00d02dcb4d5b2afb0521424 (diff) | |
| parent | 457392fa64692be0927ed641369370f02afb0420 (diff) | |
| download | php-git-e029cc4dd45c4ee5ab6678d6c732df9ed17b06d0.tar.gz | |
Merge branch 'PHP-7.4'
* PHP-7.4:
Cheaper checks for exceptions thrown from __toString()
Diffstat (limited to 'Zend/zend_operators.c')
| -rw-r--r-- | Zend/zend_operators.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 54aa7356cd..4c5a3e4ce7 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -590,14 +590,15 @@ try_again: ZEND_API zend_bool ZEND_FASTCALL _try_convert_to_string(zval *op) { - if (Z_TYPE_P(op) != IS_STRING) { - zend_string *str = zval_get_string_func(op); - if (UNEXPECTED(EG(exception))) { - return 0; - } - zval_ptr_dtor(op); - ZVAL_STR(op, str); + zend_string *str; + + ZEND_ASSERT(Z_TYPE_P(op) != IS_STRING); + str = zval_try_get_string_func(op); + if (UNEXPECTED(!str)) { + return 0; } + zval_ptr_dtor(op); + ZVAL_STR(op, str); return 1; } @@ -848,7 +849,7 @@ try_again: } /* }}} */ -ZEND_API zend_string* ZEND_FASTCALL zval_get_string_func(zval *op) /* {{{ */ +static zend_always_inline zend_string* __zval_get_string_func(zval *op, zend_bool try) /* {{{ */ { try_again: switch (Z_TYPE_P(op)) { @@ -880,7 +881,7 @@ try_again: if (!EG(exception)) { zend_throw_error(NULL, "Object of class %s could not be converted to string", ZSTR_VAL(Z_OBJCE_P(op)->name)); } - return ZSTR_EMPTY_ALLOC(); + return try ? NULL : ZSTR_EMPTY_ALLOC(); } case IS_REFERENCE: op = Z_REFVAL_P(op); @@ -893,13 +894,15 @@ try_again: } /* }}} */ +ZEND_API zend_string* ZEND_FASTCALL zval_get_string_func(zval *op) /* {{{ */ +{ + return __zval_get_string_func(op, 0); +} +/* }}} */ + ZEND_API zend_string* ZEND_FASTCALL zval_try_get_string_func(zval *op) /* {{{ */ { - zend_string *str = zval_get_string_func(op); - if (UNEXPECTED(EG(exception))) { - return NULL; - } - return str; + return __zval_get_string_func(op, 1); } /* }}} */ |
