1
0
mirror of https://github.com/golang/go synced 2024-10-03 17:11:21 -06:00
go/src/unicode
Martin Möhrmann d295174030 runtime: speed up non-ASCII rune decoding
Copies utf8 constants and EncodeRune implementation from unicode/utf8.

Adds a new decoderune implementation that is used by the compiler
in code generated for ranging over strings. It does not handle
ASCII runes since these are handled directly before calls to decoderune.

The DecodeRuneInString implementation from unicode/utf8 is not used
since it uses a lookup table that would increase the use of cpu caches.

Adds more tests that check decoding of valid and invalid utf8 sequences.

name                              old time/op  new time/op  delta
RuneIterate/range2/ASCII-4        7.45ns ± 2%  7.45ns ± 1%     ~     (p=0.634 n=16+16)
RuneIterate/range2/Japanese-4     53.5ns ± 1%  49.2ns ± 2%   -8.03%  (p=0.000 n=20+20)
RuneIterate/range2/MixedLength-4  46.3ns ± 1%  41.0ns ± 2%  -11.57%  (p=0.000 n=20+20)

new:
"".decoderune t=1 size=423 args=0x28 locals=0x0
old:
"".charntorune t=1 size=666 args=0x28 locals=0x0

Change-Id: I1df1fdb385bb9ea5e5e71b8818ea2bf5ce62de52
Reviewed-on: https://go-review.googlesource.com/28490
Run-TryBot: Martin Möhrmann <martisch@uos.de>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-17 11:25:22 +00:00
..
utf8 runtime: speed up non-ASCII rune decoding 2016-10-17 11:25:22 +00:00
utf16 all: make copyright headers consistent with one space after period 2016-03-01 23:34:33 +00:00
casetables.go
digit_test.go
digit.go
example_test.go unicode: add function level examples 2015-11-24 17:13:21 +00:00
graphic_test.go
graphic.go all: single space after period. 2016-03-02 00:13:47 +00:00
letter_test.go unicode: change SimpleFold to handle invalid runes 2016-10-12 18:30:29 +00:00
letter.go unicode: change SimpleFold to handle invalid runes 2016-10-12 18:30:29 +00:00
maketables.go unicode: upgrade to version 9.0.0 2016-06-28 15:08:11 +00:00
script_test.go unicode: upgrade to version 9.0.0 2016-06-28 15:08:11 +00:00
tables.go unicode: upgrade to version 9.0.0 2016-06-28 15:08:11 +00:00