mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
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:
parent
0eb603e3bb
commit
90b7bde615
89 changed files with 3302 additions and 1664 deletions
|
@ -78,7 +78,7 @@ static zend_attribute *get_attribute(HashTable *attributes, zend_string *lcname,
|
|||
if (attributes) {
|
||||
zend_attribute *attr;
|
||||
|
||||
ZEND_HASH_FOREACH_PTR(attributes, attr) {
|
||||
ZEND_HASH_PACKED_FOREACH_PTR(attributes, attr) {
|
||||
if (attr->offset == offset && zend_string_equals(attr->lcname, lcname)) {
|
||||
return attr;
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ static zend_attribute *get_attribute_str(HashTable *attributes, const char *str,
|
|||
if (attributes) {
|
||||
zend_attribute *attr;
|
||||
|
||||
ZEND_HASH_FOREACH_PTR(attributes, attr) {
|
||||
ZEND_HASH_PACKED_FOREACH_PTR(attributes, attr) {
|
||||
if (attr->offset == offset && ZSTR_LEN(attr->lcname) == len) {
|
||||
if (0 == memcmp(ZSTR_VAL(attr->lcname), str, len)) {
|
||||
return attr;
|
||||
|
@ -173,7 +173,7 @@ ZEND_API bool zend_is_attribute_repeated(HashTable *attributes, zend_attribute *
|
|||
{
|
||||
zend_attribute *other;
|
||||
|
||||
ZEND_HASH_FOREACH_PTR(attributes, other) {
|
||||
ZEND_HASH_PACKED_FOREACH_PTR(attributes, other) {
|
||||
if (other != attr && other->offset == attr->offset) {
|
||||
if (zend_string_equals(other->lcname, attr->lcname)) {
|
||||
return 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue