[php-src] master: Use interned strings for error_get_last()
| From: | Nikita Popov | Date: | Fri, 23 Apr 2021 09:05:21 +0000 |
| Subject: | [php-src] master: Use interned strings for error_get_last() | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-115780@lists.php.net to get a copy of this message | ||
Author: Nikita Popov (nikic)
Date: 2021-04-23T11:05:14+02:00
Commit: https://github.com/php/php-src/commit/dc7030300c5edccf5b5e996042a5b2c14790b5b1
Raw diff: https://github.com/php/php-src/commit/dc7030300c5edccf5b5e996042a5b2c14790b5b1.diff
Use interned strings for error_get_last()
We have known strings for all the array keys, use them.
Changed paths:
M ext/standard/basic_functions.c
Diff:
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index a614b40210ea..6e7d9334c0ce 100755
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -1506,13 +1506,20 @@ PHP_FUNCTION(error_get_last)
ZEND_PARSE_PARAMETERS_NONE();
if (PG(last_error_message)) {
+ zval tmp;
array_init(return_value);
- add_assoc_long_ex(return_value, "type", sizeof("type")-1,
PG(last_error_type));
- add_assoc_str_ex(return_value, "message", sizeof("message")-1,
- zend_string_copy(PG(last_error_message)));
- add_assoc_str_ex(return_value, "file", sizeof("file")-1,
- zend_string_copy(PG(last_error_file)));
- add_assoc_long_ex(return_value, "line", sizeof("line")-1,
PG(last_error_lineno));
+
+ ZVAL_LONG(&tmp, PG(last_error_type));
+ zend_hash_update(Z_ARR_P(return_value), ZSTR_KNOWN(ZEND_STR_TYPE), &tmp);
+
+ ZVAL_STR_COPY(&tmp, PG(last_error_message));
+ zend_hash_update(Z_ARR_P(return_value), ZSTR_KNOWN(ZEND_STR_MESSAGE), &tmp);
+
+ ZVAL_STR_COPY(&tmp, PG(last_error_file));
+ zend_hash_update(Z_ARR_P(return_value), ZSTR_KNOWN(ZEND_STR_FILE), &tmp);
+
+ ZVAL_LONG(&tmp, PG(last_error_lineno));
+ zend_hash_update(Z_ARR_P(return_value), ZSTR_KNOWN(ZEND_STR_LINE), &tmp);
}
}
/* }}} */