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

mempool: Optimize the votes map slices. #479

Merged
merged 1 commit into from Nov 21, 2016

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Nov 19, 2016

This optimizes the vote map by making better use of Go's slice properties. In particular, instead of creating a slice with empty entries and iterating to find the next empty entry, just create the slice with a cap
and append entries as needed. This allows the code simply take the len of the slice and range over it without needing additional code to deal with nil entries.

While here, it also makes a few comments and returns more consistent with the rest of the code base.

This optimizes the vote map by making better use of Go's slice properties.
In particular, instead of creating a slice with empty entries and
iterating to find the next empty entry, just create the slice with a cap
and append entries as needed.  This allows the code simply take the len
of the slice and range over it without needing additional code to deal
with nil entries.

While here, it also makes a few comments and returns more consistent
with the rest of the code base.
Copy link
Member

@dajohi dajohi left a comment

Choose a reason for hiding this comment

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

OK

@alexlyp
Copy link
Member

alexlyp commented Nov 21, 2016

OK tACK on tesnet

@alexlyp alexlyp merged commit d0b3a35 into decred:master Nov 21, 2016
@davecgh davecgh deleted the mempool_vote_map_optimization branch November 22, 2016 05:22
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.

None yet

3 participants