-
Notifications
You must be signed in to change notification settings - Fork 60
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
address some linting issues, and small refactor, performance optimizations #103
Open
thaJeztah
wants to merge
7
commits into
opencontainers:master
Choose a base branch
from
thaJeztah:perf_and_shadow_nits
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
- rename "digester" vars that shadowed package-level digester type - rename "hexdigestbytes" to be properly camelCase - use "errors.Is()" instead of straight comparing errors Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
No need to validate the format if we previously accepted it to be registered. Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Just for convenience ':-) Before: pkg: github.com/opencontainers/go-digest/digestset BenchmarkAdd10-10 183613 6368 ns/op BenchmarkAdd100-10 15739 75741 ns/op BenchmarkAdd1000-10 1430 831884 ns/op BenchmarkRemove10-10 169999 6984 ns/op BenchmarkRemove100-10 15312 78299 ns/op BenchmarkRemove1000-10 1470 815144 ns/op BenchmarkLookup10-10 27067897 43.69 ns/op BenchmarkLookup100-10 17203653 69.17 ns/op BenchmarkLookup1000-10 13043708 96.32 ns/op BenchmarkShortCode10-10 3574094 334.5 ns/op BenchmarkShortCode100-10 320438 3782 ns/op BenchmarkShortCode1000-10 29110 41460 ns/op After: pkg: github.com/opencontainers/go-digest/digestset BenchmarkAdd10 BenchmarkAdd10-10 176776 6400 ns/op 608 B/op 12 allocs/op BenchmarkAdd100-10 15267 76016 ns/op 5746 B/op 102 allocs/op BenchmarkAdd1000-10 1426 833977 ns/op 56267 B/op 1002 allocs/op BenchmarkRemove10-10 169448 7043 ns/op 128 B/op 2 allocs/op BenchmarkRemove100-10 15249 78730 ns/op 944 B/op 2 allocs/op BenchmarkRemove1000-10 1444 819247 ns/op 8240 B/op 2 allocs/op BenchmarkLookup10-10 27042379 45.68 ns/op 0 B/op 0 allocs/op BenchmarkLookup100-10 17098725 69.72 ns/op 0 B/op 0 allocs/op BenchmarkLookup1000-10 12769602 92.97 ns/op 0 B/op 0 allocs/op BenchmarkShortCode10-10 3551202 332.1 ns/op 630 B/op 2 allocs/op BenchmarkShortCode100-10 313929 3805 ns/op 5449 B/op 4 allocs/op BenchmarkShortCode1000-10 28963 41373 ns/op 81992 B/op 3 allocs/op Signed-off-by: Sebastiaan van Stijn <[email protected]>
Remove fmt.Sprintf and use string-concatenation instead to reduce some allocations. Before / After: BenchmarkNewDigestFromEncoded-10 8474174 128.4 ns/op 112 B/op 3 allocs/op BenchmarkNewDigestFromEncoded-10 37912695 31.55 ns/op 80 B/op 1 allocs/op BenchmarkNewDigestFromBytes-10 5087299 237.2 ns/op 200 B/op 5 allocs/op BenchmarkNewDigestFromBytes-10 8416543 146.8 ns/op 168 B/op 3 allocs/op Signed-off-by: Sebastiaan van Stijn <[email protected]>
thaJeztah
requested review from
AkihiroSuda,
dmcgowan,
stevvooe and
vbatts
as code owners
July 2, 2024 12:15
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
address some linting issues
testdigest: fix package GoDoc to be in the right format
remove import aliases
RegisterAlgorithm: skip regex if not needed
No need to validate the format if we previously accepted it to be
registered.
use errors.New() for errors that don't need formatting
digestset: report allocations in benchmarks
Just for convenience ':-)
Before:
After:
remove unneeded fmt.Sprintf and indirections
Remove fmt.Sprintf and use string-concatenation instead to reduce
some allocations.
Before / After: