Uh oh!
There was an error while loading. Please reload this page.
Remove allocation for ZSTs - #92
Conversation
emilio
left a comment
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.
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 |
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