Skip to content

Proof of concept of optimized Set#4

Draft
applejag wants to merge 2 commits into
firefly-zero:mainfrom
applejag:feature/alloc-in-set
Draft

Proof of concept of optimized Set#4
applejag wants to merge 2 commits into
firefly-zero:mainfrom
applejag:feature/alloc-in-set

Conversation

@applejag
Copy link
Copy Markdown
Contributor

@applejag applejag commented Apr 29, 2026

This is merely a suggestion. If you want to see this added then I'll override the Set implementation with the Set2 implementation.

Removes the need for allocating when adding new entries to the set. Still needs an allocation when the slice grows, but that can also be fixed by setting a big enough capacity on boot. Could even get rid of append and tracking the length manually, which would only allow a maximum of X number of projectiles at a time. But that's a realistic tradeoff.

The design of .iter() returning []bool is intended to prevent the user to try use a copy of the items from the items slice, and to avoid having to copy bigger structs back and forth. The "structs of arrays" pattern also produces better struct field padding, but I don't know if that matters in the WASM runtime that Firefly uses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant