go/src/unicode
Joe Tsai 8eca08611a unicode/utf8: optimize ValidRune
Re-writing the switch statement as a single boolean expression
reduces the number of branches that the compiler generates.
It is also arguably easier to read as a pair of numeric ranges
that valid runes can exist in.

No test changes since the existing test does a good job of
testing all of the boundaries.

This change was to gain back some performance after a correctness
fix done in http://golang.org/cl/32123.

The correctness fix (CL/32123) slowed down the benchmarks slightly:
	benchmark                   old ns/op     new ns/op     delta
	BenchmarkIndexRune/10-4     19.3          21.6          +11.92%
	BenchmarkIndexRune/32-4     33.6          35.2          +4.76%

Since the fix relies on utf8.ValidRune, this CL improves benchmarks:
	benchmark                   old ns/op     new ns/op     delta
	BenchmarkIndexRune/10-4     21.6          20.0          -7.41%
	BenchmarkIndexRune/32-4     35.2          33.5          -4.83%

Change-Id: Ib1ca10a2e29c90e879a8ef9b7221c33e85d015d8
Reviewed-on: https://go-review.googlesource.com/32122
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-26 23:02:52 +00:00
..
utf8 unicode/utf8: optimize ValidRune 2016-10-26 23:02:52 +00:00
utf16 all: make copyright headers consistent with one space after period 2016-03-01 23:34:33 +00:00
casetables.go
digit.go
digit_test.go
example_test.go unicode: add function level examples 2015-11-24 17:13:21 +00:00
graphic.go all: single space after period. 2016-03-02 00:13:47 +00:00
graphic_test.go build: move package sources from src/pkg to src 2014-09-08 00:08:51 -04:00
letter.go unicode: change SimpleFold to handle invalid runes 2016-10-12 18:30:29 +00:00
letter_test.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