Repository navigation
Support ZendStr keys when inserting into ZendHashTable #742
|
Hi, First of all thank you to the maintainers for all your work on ext-php-rs. I was wondering if it would make sense to support using ZendStr as keys when inserting values into ZendHashTable. One use case that I ran into is using interned strings as keys. Corresponding Zend API would be functions like zend_hash_add_or_update, zend_hash_update, zend_hash_add, ..etc. Would be happy to try my hands at a PR if you think it would make sense. Thanks |
Replies: 1 comment
|
Thanks for proposing this! The current
I can see real wins for interned hotkeys cached at MINIT, mangled property keys ( A few concerns for the PR:
Happy to review a PR! |
Thanks for proposing this!
The current
zend_hash_str_*path does a freshzend_string_init(emalloc + memcpy + hash recomputation) on every new bucket. Letting callers pass azend_stringdirectly hitszend_hash_updateand friends, which:ZSTR_H(key)(no re-hash),HASH_FLAG_STATIC_KEYSset,I can see real wins for interned hotkeys cached at MINIT, mangled property keys (
\0Class\0prop), andzend_stringround-tripping from PHP into a new array.A few concerns for the PR:
&strandStringpaths untouched.