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

Optimize member set by using plain Go maps and parent-child chaining #589

Merged
merged 3 commits into from
Feb 9, 2021

Conversation

turbolent
Copy link
Member

Description

Refactor the member set from using HAMT sets to Go map and parent-child chaining, just like in activations.

This improves performance of BenchmarkCheckContractInterfaceFungibleTokenConformance by ~8%.


For contributor use:

  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

result := NewMemberSet(nil)

_ = ms.ForEach(func(member *Member) error {
if !otherMS.Contains(member) {
Copy link
Member

Choose a reason for hiding this comment

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

Just a minor suggestion: inverting the condition could reduce the number of return statements to one.

Copy link
Member Author

Choose a reason for hiding this comment

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

I usually try to structure code with early exits which avoids deep nesting. This also seems to be idiomatic / often seen in Go code.

@turbolent turbolent merged commit 2c2db26 into master Feb 9, 2021
@turbolent turbolent deleted the bastian/optimize-memberset branch May 18, 2021 17:39
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.

3 participants