Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor memory data #836

Merged
merged 11 commits into from
Oct 27, 2021
Merged

Refactor memory data #836

merged 11 commits into from
Oct 27, 2021

Conversation

emilk
Copy link
Owner

@emilk emilk commented Oct 24, 2021

This refactors the widget state storage introduced by @optozorax in #257

  • Unify the four buckets (data, data_temp, id_data and id_data_temp) into a single data.
    • Less complexity, and also less chance of error (storing in one bucket, reading from another).
  • Store data by Id and TypeId.
    • Users can thus reuse the same Id to store many types.
    • Uses a simple xor of id and typeid, which is fast and good since both id and typeid are already high-entropy hashes.
  • Use different suffixes on the functions to pick if you want the data persisted or not (get_temp, insert_persisted, etc).
    • Writing with one suffix and reading with the other works.
  • To store state not bound to a specific Id (i.e. only based on type), use the new Id::null as the key.

@emilk emilk force-pushed the refactor-memory-data branch 2 times, most recently from 29a48c4 to 4e7e28c Compare October 24, 2021 18:00
@emilk emilk marked this pull request as ready for review October 24, 2021 18:25
@emilk emilk merged commit 8e4fd94 into master Oct 27, 2021
@emilk emilk deleted the refactor-memory-data branch October 27, 2021 06:51
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