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: use less memory in verifier_cache by storing zero-sized type instead of bool #2536

Merged
merged 1 commit into from
Feb 7, 2019

Conversation

JeremyRubin
Copy link
Contributor

Because the presence of the entry is sufficient to show that it verified true, we no longer need to store a bool type.

A node in the LRU Cache's Map is 2 pointers, the key, and then the value. Via padding this works out to cost 4 bytes for the bool. This represents a total memory savings of 0.4 MB, which is not terribly much, but nice to do.

This PR also removes the use of .unwrap_or(&mut false) when checking for entries.

Copy link
Contributor

@ignopeverell ignopeverell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shorter and cleaner, very nice!

@ignopeverell ignopeverell added this to the 1.0.2 milestone Feb 6, 2019
@hashmap hashmap merged commit 1f7ea49 into mimblewimble:master Feb 7, 2019
@antiochp
Copy link
Member

antiochp commented Feb 7, 2019

\o/

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

Successfully merging this pull request may close these issues.

4 participants