Optimizes and tests FormatInt by removing inefficient string concatenation but also making it so much clearer with how one would express adding thousand separators in natural language. It uses a combination of strings.Builder whose values can be grown The performance improvement is stark in every dimension: ```shell $ benchstat before.txt after3.txt name old time/op new time/op delta DecimalValueRendererFormat-8 4.48µs ± 1% 2.11µs ± 2% -52.90% (p=0.000 n=10+10) name old alloc/op new alloc/op delta DecimalValueRendererFormat-8 3.62kB ± 0% 0.78kB ± 0% -78.59% (p=0.000 n=10+10) name old allocs/op new allocs/op delta DecimalValueRendererFormat-8 83.0 ± 0% 28.0 ± 0% -66.27% (p=0.000 n=10+10) ``` While here, also simplified zero padding for LegacyNewDecFromStr simply by using strings.Repeat instead of a convoluted fmt.Sprintf+strconv.Itoa. Fixes #14008 Fixes #14003 Co-authored-by: Marko <marbar3778@yahoo.com> |
||
|---|---|---|
| .. | ||
| CHANGELOG.md | ||
| dec_internal_test.go | ||
| dec_test.go | ||
| dec.go | ||
| doc.go | ||
| go.mod | ||
| go.sum | ||
| int_internal_test.go | ||
| int_test.go | ||
| int.go | ||
| proto.go | ||
| sonar-project.properties | ||
| uint_internal_test.go | ||
| uint_test.go | ||
| uint.go | ||