Use more compact representation for packed arrays.

- for packed arrays we store just an array of zvals without keys.
- the elements of packed array are accessible throuf as ht->arPacked[i]
  instead of ht->arData[i]
- in addition to general ZEND_HASH_FOREACH_* macros, we introduced similar
  familied for packed (ZEND_HASH_PACKED_FORECH_*) and real hashes
  (ZEND_HASH_MAP_FOREACH_*)
- introduced an additional family of macros to access elements of array
  (packed or real hashes) ZEND_ARRAY_ELEMET_SIZE, ZEND_ARRAY_ELEMET_EX,
  ZEND_ARRAY_ELEMET, ZEND_ARRAY_NEXT_ELEMENT, ZEND_ARRAY_PREV_ELEMENT
- zend_hash_minmax() prototype was changed to compare only values

Because of smaller data set, this patch may show performance improvement
on some apps and benchmarks that use packed arrays. (~1% on PHP-Parser)

TODO:
    - sapi/phpdbg needs special support for packed arrays (WATCH_ON_BUCKET).
    - zend_hash_sort_ex() may require converting packed arrays to hash.
This commit is contained in:
Dmitry Stogov 2021-11-03 15:18:26 +03:00
parent 0eb603e3bb
commit 90b7bde615
89 changed files with 3302 additions and 1664 deletions

View file

@ -125,7 +125,7 @@ PHPAPI ZEND_COLD void display_ini_entries(zend_module_entry *module)
module_number = 0;
}
ZEND_HASH_FOREACH_PTR(EG(ini_directives), ini_entry) {
ZEND_HASH_MAP_FOREACH_PTR(EG(ini_directives), ini_entry) {
if (ini_entry->module_number != module_number) {
continue;
}
@ -812,7 +812,7 @@ PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int
zval *data;
/* Walk through config hash and alter matching ini entries using the values found in the hash */
ZEND_HASH_FOREACH_STR_KEY_VAL(source_hash, str, data) {
ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(source_hash, str, data) {
zend_string *data_str = zend_string_dup(Z_STR_P(data), 0);
zend_alter_ini_entry_ex(str, data_str, modify_type, stage, 0);
zend_string_release(data_str);