• Martin Möhrmann's avatar
    runtime: speed up non-ASCII rune decoding · d2951740
    Martin Möhrmann authored
    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: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    d2951740
Name
Last commit
Last update
..
utf16 Loading commit data...
utf8 Loading commit data...
casetables.go Loading commit data...
digit.go Loading commit data...
digit_test.go Loading commit data...
example_test.go Loading commit data...
graphic.go Loading commit data...
graphic_test.go Loading commit data...
letter.go Loading commit data...
letter_test.go Loading commit data...
maketables.go Loading commit data...
script_test.go Loading commit data...
tables.go Loading commit data...