-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for empty immutable shared arrays
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.
- Loading branch information
1 parent
464407b
commit 8316c30
Showing
6 changed files
with
141 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters