go/src/fmt
Martin Möhrmann 83765d135f fmt: optimize string truncation
Count only the runes up to the requested precision
to decide where to truncate a string.

Change the loop within truncate to need fewer jumps.

name                     old time/op  new time/op  delta
SprintfTruncateString-2   188ns ± 3%   155ns ± 3%  -17.43%  (p=0.000 n=20+20)

Change-Id: I17ca9fc0bb8bf7648599df48e4785251bbc31e99
Reviewed-on: https://go-review.googlesource.com/20098
Reviewed-by: Rob Pike <r@golang.org>
2016-03-02 20:51:38 +00:00
..
doc.go fmt: clarify reflect.Value printing 2015-10-19 18:29:36 +00:00
export_test.go all: make copyright headers consistent with one space after period 2016-03-01 23:34:33 +00:00
fmt_test.go fmt: optimize string truncation 2016-03-02 20:51:38 +00:00
format.go fmt: optimize string truncation 2016-03-02 20:51:38 +00:00
print.go fmt: make identification of string arguments consistent 2016-03-01 07:36:06 +00:00
scan.go all: single space after period. 2016-03-02 00:13:47 +00:00
scan_test.go all: single space after period. 2016-03-02 00:13:47 +00:00
stringer_test.go