You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why:
- Since PHP 7.3, it's possible for extensions to create zvals backed by
an immutable shared hashtable via the ZVAL_EMPTY_ARRAY macro.
- This helps avoid redundant hashtable allocations when returning empty arrays
back to userland PHP code, and could likewise be beneficial for Rust extensions too.
What:
- Add ZendHashTable::new_empty_immutable() to obtain a ZendHashTable
that is actually an empty immutable shared hashtable.
- Add ZendHashTable::is_immutable(). Use it to avoid attempting to
free the immutable shared hashtable on drop, and to set appropriate
type flags when initializing a zval with a ZendHashTable.
- Make ZendHashTable's TryFrom implementations from Vec and HashMap return
an empty immutable shared hashtable if the input collection was empty.
Although this would allow every user to automatically benefit from
this optimization, I'm not convinced about this part because this is technically a
breaking change for consumers that construct ZendHashTables via these
converters in their Rust code. Maybe it'd be better to not change the
converters and let projects explicitly use ::new_empty_immutable if they
deem the optimization would be useful.
0 commit comments