Skip to content

Commit

Permalink
fix(cmd/aminoscan): set len=0 in a slice initialization (#2971)
Browse files Browse the repository at this point in the history
<!-- please provide a detailed description of the changes made in this
pull request. -->

<details><summary>Contributors' checklist...</summary>

- [ ] Added new tests, or not needed, or not feasible
- [x] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [ ] Updated the official documentation or not needed
- [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [ ] Added references to related issues and PRs
- [ ] Provided any useful hints for running manual tests
</details>


The intention here should be to initialize a slice with a capacity of
`len(args)` rather than initializing the length of this slice.

The online demo: https://go.dev/play/p/q1BcVCmvidW
  • Loading branch information
rusttech authored Oct 18, 2024
1 parent 4d86229 commit b655cd2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tm2/pkg/amino/cmd/aminoscan/colors.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func treat(s string, color string) string {
}

func treatAll(color string, args ...interface{}) string {
parts := make([]string, len(args))
parts := make([]string, 0, len(args))
for _, arg := range args {
parts = append(parts, treat(fmt.Sprintf("%v", arg), color))
}
Expand Down

1 comment on commit b655cd2

@github-actions
Copy link

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Go Benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.

Benchmark suite Current: b655cd2 Previous: 4d86229 Ratio
BenchmarkBinary/EmptyStruct:encode 507.1 ns/op 96 B/op 2 allocs/op 289.4 ns/op 96 B/op 2 allocs/op 1.75
BenchmarkBinary/EmptyStruct:encode - ns/op 507.1 ns/op 289.4 ns/op 1.75
BenchmarkBinary/EmptyStruct:decode 290.9 ns/op 0 B/op 0 allocs/op 143 ns/op 0 B/op 0 allocs/op 2.03
BenchmarkBinary/EmptyStruct:decode - ns/op 290.9 ns/op 143 ns/op 2.03
BenchmarkBinary/ShortArraysStruct:encode 791.2 ns/op 192 B/op 4 allocs/op 623.6 ns/op 192 B/op 4 allocs/op 1.27
BenchmarkBinary/ShortArraysStruct:encode - ns/op 791.2 ns/op 623.6 ns/op 1.27
BenchmarkBinary/ShortArraysStruct:decode 377.6 ns/op 0 B/op 0 allocs/op 229.5 ns/op 0 B/op 0 allocs/op 1.65
BenchmarkBinary/ShortArraysStruct:decode - ns/op 377.6 ns/op 229.5 ns/op 1.65
BenchmarkBcryptGenerateFromPassword/benchmark-security-param 63872849 ns/op 5130 B/op 9 allocs/op 31986249 ns/op 5125 B/op 9 allocs/op 2.00
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - ns/op 63872849 ns/op 31986249 ns/op 2.00
BenchmarkBcryptGenerateFromPassword/benchmark-security-param 127533601 ns/op 5139 B/op 9 allocs/op 31986249 ns/op 5125 B/op 9 allocs/op 3.99
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - ns/op 127533601 ns/op 31986249 ns/op 3.99
BenchmarkBcryptGenerateFromPassword/benchmark-security-param 254948507 ns/op 5158 B/op 9 allocs/op 31986249 ns/op 5125 B/op 9 allocs/op 7.97
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - ns/op 254948507 ns/op 31986249 ns/op 7.97
BenchmarkBcryptGenerateFromPassword/benchmark-security-param 509821704 ns/op 5196 B/op 10 allocs/op 31986249 ns/op 5125 B/op 9 allocs/op 15.94
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - ns/op 509821704 ns/op 31986249 ns/op 15.94
BenchmarkBcryptGenerateFromPassword/benchmark-security-param 1019502736 ns/op 5736 B/op 15 allocs/op 31986249 ns/op 5125 B/op 9 allocs/op 31.87
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - ns/op 1019502736 ns/op 31986249 ns/op 31.87
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - allocs/op 15 allocs/op 9 allocs/op 1.67
BenchmarkBcryptGenerateFromPassword/benchmark-security-param 2039029968 ns/op 5736 B/op 15 allocs/op 31986249 ns/op 5125 B/op 9 allocs/op 63.75
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - ns/op 2039029968 ns/op 31986249 ns/op 63.75
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - allocs/op 15 allocs/op 9 allocs/op 1.67
BenchmarkSigning 82686 ns/op 1856 B/op 36 allocs/op 25728 ns/op 64 B/op 1 allocs/op 3.21
BenchmarkSigning - ns/op 82686 ns/op 25728 ns/op 3.21
BenchmarkSigning - B/op 1856 B/op 64 B/op 29
BenchmarkSigning - allocs/op 36 allocs/op 1 allocs/op 36
BenchmarkSigning 84300 ns/op 1856 B/op 36 allocs/op 25728 ns/op 64 B/op 1 allocs/op 3.28
BenchmarkSigning - ns/op 84300 ns/op 25728 ns/op 3.28
BenchmarkSigning - B/op 1856 B/op 64 B/op 29
BenchmarkSigning - allocs/op 36 allocs/op 1 allocs/op 36
BenchmarkVerification 172454 ns/op 864 B/op 19 allocs/op 61301 ns/op 0 B/op 0 allocs/op 2.81
BenchmarkVerification - ns/op 172454 ns/op 61301 ns/op 2.81
BenchmarkVerification - B/op 864 B/op 0 B/op +∞
BenchmarkVerification - allocs/op 19 allocs/op 0 allocs/op +∞
BenchmarkVerification 160357 ns/op 864 B/op 19 allocs/op 61301 ns/op 0 B/op 0 allocs/op 2.62
BenchmarkVerification - ns/op 160357 ns/op 61301 ns/op 2.62
BenchmarkVerification - B/op 864 B/op 0 B/op +∞
BenchmarkVerification - allocs/op 19 allocs/op 0 allocs/op +∞
BenchmarkRandomBytes/random 68.45 ns/op 16 B/op 1 allocs/op 33.09 ns/op 4 B/op 1 allocs/op 2.07
BenchmarkRandomBytes/random - ns/op 68.45 ns/op 33.09 ns/op 2.07
BenchmarkRandomBytes/random - B/op 16 B/op 4 B/op 4
BenchmarkRandomBytes/random 104.4 ns/op 32 B/op 1 allocs/op 33.09 ns/op 4 B/op 1 allocs/op 3.16
BenchmarkRandomBytes/random - ns/op 104.4 ns/op 33.09 ns/op 3.16
BenchmarkRandomBytes/random - B/op 32 B/op 4 B/op 8
BenchmarkRandomBytes/random 265 ns/op 112 B/op 1 allocs/op 33.09 ns/op 4 B/op 1 allocs/op 8.01
BenchmarkRandomBytes/random - ns/op 265 ns/op 33.09 ns/op 8.01
BenchmarkRandomBytes/random - B/op 112 B/op 4 B/op 28
BenchmarkRandomBytes/random 2283 ns/op 1024 B/op 1 allocs/op 33.09 ns/op 4 B/op 1 allocs/op 68.99
BenchmarkRandomBytes/random - ns/op 2283 ns/op 33.09 ns/op 68.99
BenchmarkRandomBytes/random - B/op 1024 B/op 4 B/op 256
BenchmarkSmall/boltdb-1000-100-16-40/update 1338258 ns/op 42017 B/op 371 allocs/op 997556 ns/op 37335 B/op 373 allocs/op 1.34
BenchmarkSmall/boltdb-1000-100-16-40/update - ns/op 1338258 ns/op 997556 ns/op 1.34
BenchmarkSmall/memdb-1000-100-16-40/block 16745593 ns/op 9163746 B/op 166999 allocs/op 13294578 ns/op 6577355 B/op 116750 allocs/op 1.26
BenchmarkSmall/memdb-1000-100-16-40/block - ns/op 16745593 ns/op 13294578 ns/op 1.26
BenchmarkSmall/memdb-1000-100-16-40/block - B/op 9163746 B/op 6577355 B/op 1.39
BenchmarkSmall/memdb-1000-100-16-40/block - allocs/op 166999 allocs/op 116750 allocs/op 1.43
BenchmarkMedium/boltdb-100000-100-16-40/update 6917271 ns/op 134547 B/op 1043 allocs/op 5417526 ns/op 101670 B/op 859 allocs/op 1.28
BenchmarkMedium/boltdb-100000-100-16-40/update - ns/op 6917271 ns/op 5417526 ns/op 1.28
BenchmarkMedium/boltdb-100000-100-16-40/update - B/op 134547 B/op 101670 B/op 1.32
BenchmarkMedium/boltdb-100000-100-16-40/update - allocs/op 1043 allocs/op 859 allocs/op 1.21
BenchmarkMedium/memdb-100000-100-16-40/update 1246634 ns/op 371393 B/op 7356 allocs/op 1007055 ns/op 250726 B/op 4829 allocs/op 1.24
BenchmarkMedium/memdb-100000-100-16-40/update - ns/op 1246634 ns/op 1007055 ns/op 1.24
BenchmarkMedium/memdb-100000-100-16-40/update - B/op 371393 B/op 250726 B/op 1.48
BenchmarkMedium/memdb-100000-100-16-40/update - allocs/op 7356 allocs/op 4829 allocs/op 1.52
BenchmarkLevelDBBatchSizes/goleveldb-100000-400-16-40/update - B/op 47608 B/op 38764 B/op 1.23
BenchmarkLevelDBBatchSizes/goleveldb-100000-400-16-40/update - allocs/op 581 allocs/op 449 allocs/op 1.29
BenchmarkHash/ripemd160 2837 ns/op 25 B/op 1 allocs/op 699.2 ns/op 25 B/op 1 allocs/op 4.06
BenchmarkHash/ripemd160 - ns/op 2837 ns/op 699.2 ns/op 4.06
BenchmarkHash/sha2-256 522.6 ns/op 33 B/op 1 allocs/op 170.4 ns/op 33 B/op 1 allocs/op 3.07
BenchmarkHash/sha2-256 - ns/op 522.6 ns/op 170.4 ns/op 3.07
BenchmarkHash/sha3-256 1840 ns/op 33 B/op 1 allocs/op 714 ns/op 33 B/op 1 allocs/op 2.58
BenchmarkHash/sha3-256 - ns/op 1840 ns/op 714 ns/op 2.58
BenchmarkWriteSecretConnection 5456 ns/op 0 B/op 0 allocs/op 4024 ns/op 0 B/op 0 allocs/op 1.36
BenchmarkWriteSecretConnection - ns/op 5456 ns/op 4024 ns/op 1.36
BenchmarkReadSecretConnection 3742 ns/op 0 B/op 0 allocs/op 2359 ns/op 0 B/op 0 allocs/op 1.59
BenchmarkReadSecretConnection - ns/op 3742 ns/op 2359 ns/op 1.59

This comment was automatically generated by workflow using github-action-benchmark.

CC: @ajnavarro @thehowl @zivkovicmilos

Please sign in to comment.