-
-
Notifications
You must be signed in to change notification settings - Fork 114
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
efficient struct packing #264
Conversation
3121db1
to
ce997d8
Compare
Codecov Report
@@ Coverage Diff @@
## master #264 +/- ##
==========================================
- Coverage 63.79% 63.79% -0.01%
==========================================
Files 79 79
Lines 5638 5640 +2
==========================================
+ Hits 3597 3598 +1
Misses 1683 1683
- Partials 358 359 +1
Continue to review full report at Codecov.
|
I still get one report of suboptimal struct size:
|
Kudos, SonarCloud Quality Gate passed! |
@@ -11,6 +12,10 @@ func (t Token) String() string { | |||
return hex.EncodeToString(t) | |||
} | |||
|
|||
func (t Token) Hash() uint64 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could cache the value if the function is used often, eg:
type Token struct {
data []byte
hash uint64
}
Calculate the value on first use, save it and then use only cached value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hash is a very cheap operation so was can leave it as is otherwise we need to introduce a constructor
which fills the value.
No description provided.