mirror of
https://github.com/php/frankenphp.git
synced 2026-03-24 00:52:11 +01:00
perf: avoid extra string allocation in get_full_env() (#1382)
* Avoid extra string allocation in get_full_env() We can pass the key directly to add_assoc_str(). * Use add_assoc_str_ex
This commit is contained in:
@@ -167,15 +167,11 @@ PHPAPI void get_full_env(zval *track_vars_array) {
|
||||
go_string key = full_env.r0[i * 2];
|
||||
go_string val = full_env.r0[i * 2 + 1];
|
||||
|
||||
// create PHP strings for key and value
|
||||
zend_string *key_str = zend_string_init(key.data, key.len, 0);
|
||||
// create PHP string for the value
|
||||
zend_string *val_str = zend_string_init(val.data, val.len, 0);
|
||||
|
||||
// add to the associative array
|
||||
add_assoc_str(track_vars_array, ZSTR_VAL(key_str), val_str);
|
||||
|
||||
// release the key string
|
||||
zend_string_release(key_str);
|
||||
add_assoc_str_ex(track_vars_array, key.data, key.len, val_str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user