feat(types): expose IsPacked to help dealing with hashmaps and lists in Go code#1977
Merged
Merged
Conversation
alexandre-daubois
force-pushed
the
ht-is-packed-expose
branch
from
November 14, 2025 11:32
ba65d23 to
1d438c5
Compare
dunglas
reviewed
Nov 14, 2025
|
|
||
| // IsPacked determines if the given zval pointer represents a packed array (list). | ||
| // Returns false if the zval is nil, not an array, or not packed. | ||
| func IsPacked(zval unsafe.Pointer) bool { |
Member
There was a problem hiding this comment.
Shouldn't it take a HashTable instead of a zval?
Member
Author
There was a problem hiding this comment.
Exported functions receive arrays as a zval. That's why I preferred to create a new function instead of just exposing htIsPacked: it's a bit more flexible and allow a quick check without having to do manual casts
Member
Author
There was a problem hiding this comment.
Ah yes, let's wait for it to be merged before going forward with this one then 🙂
Member
Author
There was a problem hiding this comment.
Updated a bit, but actually we must use unsafe.Pointer to be compatible with CGO
alexandre-daubois
force-pushed
the
ht-is-packed-expose
branch
2 times, most recently
from
December 15, 2025 10:02
eb26597 to
d6091eb
Compare
alexandre-daubois
marked this pull request as draft
December 15, 2025 10:18
alexandre-daubois
force-pushed
the
ht-is-packed-expose
branch
from
December 15, 2025 10:19
d6091eb to
fb15e9c
Compare
Member
Author
|
To be merged after #1731 |
alexandre-daubois
force-pushed
the
ht-is-packed-expose
branch
from
December 15, 2025 12:04
fb15e9c to
fe3b788
Compare
alexandre-daubois
marked this pull request as ready for review
December 15, 2025 13:58
alexandre-daubois
force-pushed
the
ht-is-packed-expose
branch
from
December 15, 2025 13:59
fe3b788 to
5d9bcde
Compare
Member
|
Thanks! |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Because the API is different depending on if you deal with hash maps or lists, it would be nice to expose a method that returns whether the hashtable is packed.
My use case: I'm getting back to callable support and while writing a custom
array_map(), I want to keep indexes if it's not a list. I have to check whether the provided hash table is packed or not.