-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid using pointers to sync mutexes or maps in struct fields. We can already take the address of a struct field, and all of these methods on the struct type take a pointer receiver, so there's no need to add another pointer indirection. Note that bufioWithMutex now stores a non-pointer mutex, so it has to itself be a pointer in the sync.Map entries. This is fine, since Go's interface values always hold pointers, so we can't really avoid bufioWithMutex from being stored as a pointer. adminToken is a scalar value, so it can be an atomic instead. Note that there isn't atomic.String like e.g. atomic.Bool, so instead we use atomic.Pointer[string], which is still easier. While here, make the field names in MockBlockStore more intuitive, and it itself doesn't need to be a pointer field either.
- Loading branch information
Showing
6 changed files
with
28 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters