Remove allocation for ZSTs - #92
Open
Baptistemontan wants to merge 4 commits into
Open
Conversation
emilio
reviewed
Sep 1, 2026
emilio
left a comment
Collaborator
There was a problem hiding this comment.
Curious, can you elaborate on what's the rationale for this? It seems somewhat complicated and having an array of ZSTs is already pretty edgecasey.
In general, I'd rather keep the differences between the gecko-ffi path and the other as small as possible.
Author
|
Deliberately constructing a Vec of ZSTs is very niche, but it's actually pretty common when generics comes into play, deeply nested in data structures. This lib might be a bridge for Gecko but it's used a lot outside of that space by other people, and removing allocations for ZSTs is basically free. Well I'm that someone lol And for keeping the same paths, it could be enabled on both since ZSTs should'nt be passed to C++ anyway |
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.
Store the length as a
NonZero<usize>inside theNonNull<Header>, the pointer is actually never read for ZSTs, when one is needed just create a dangling one.The only problem is that now the length is off by one (as it can't be 0), this makes the maximum capacity
usize::MAX - 1instead, this might be a breaking change ?Did'nt enabled those optimizations for
feature = "gecko-ffi", as it can't be turned intonsTArray, tho from my understanding ZSTs are undefined in C++ so it would be UB to turn a ThinVec of ZSTs into a nsTArray anyway, but I prefer to get confirmation first