1
0
mirror of https://github.com/golang/go synced 2024-09-30 13:28:38 -06:00
go/src
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
..
archive archive/tar: validate sparse headers in parsePAX 2016-10-22 16:35:14 +00:00
bufio bufio: remove unnecessary "continue" 2016-10-24 14:49:44 +00:00
builtin
bytes bytes, strings: fix regression in IndexRune 2016-10-26 23:02:27 +00:00
cmd cmd/compile: avoid truncating fieldname var locations 2016-10-26 21:14:46 +00:00
compress all: minor vet fixes 2016-10-24 17:27:37 +00:00
container
context context: add comments to the WithCancel example, apply minor improvements 2016-10-26 22:35:07 +00:00
crypto crypto/x509: use Certificate.Equals and CertPool.contains. 2016-10-26 22:58:21 +00:00
database/sql database/sql: fix possible context leak in test 2016-10-24 17:56:11 +00:00
debug cmd/dist: use debug/pe directly for cmd/link 2016-10-17 15:22:17 +00:00
encoding encoding/json: marshal the RawMessage value type the same as its pointer type 2016-10-26 21:03:00 +00:00
errors
expvar expvar: add Value methods 2016-10-13 21:39:03 +00:00
flag flag: arrange for FlagSet.Usage to be non-nil by default 2016-10-26 16:13:40 +00:00
fmt fmt: document that unexported struct fields don't get the String/Error treatment 2016-10-26 13:56:45 +00:00
go go/scanner: recognize invalid floating-point constant exponent 2016-10-26 23:02:42 +00:00
hash
html html/template: add test case for unbounded template expansion 2016-10-24 15:44:30 +00:00
image image/color: improve speed of RGBA methods 2016-10-25 07:51:17 +00:00
index/suffixarray
internal syscall: use ERROR_IO_PENDING value in errnoErr 2016-10-22 23:05:01 +00:00
io io: clarify Pipe docs 2016-10-18 12:53:56 +00:00
log all: freeze net/rpc and reword the 'frozen' message in other frozen packages 2016-10-26 16:11:07 +00:00
math math/cmplx: prevent infinite loop in tanSeries 2016-10-25 18:32:22 +00:00
mime net/http: multipart ReadForm close file after copy 2016-10-05 16:35:03 +00:00
net net/http/httptest: doc tweaks 2016-10-26 22:55:05 +00:00
os os: consider only files from #M as regular on Plan 9 2016-10-26 16:18:00 +00:00
path path/filepath: make TestToNorm robust 2016-10-25 01:57:05 +00:00
plugin plugin: mention OS X support and concurrency 2016-10-19 17:24:19 +00:00
reflect runtime: simplify reflectcall write barriers 2016-10-26 15:44:44 +00:00
regexp regexp: avoid alloc in QuoteMeta when not quoting 2016-10-19 07:09:08 +00:00
runtime cmd/compile: avoid truncating fieldname var locations 2016-10-26 21:14:46 +00:00
sort sort: fix a slice benchmark not using the stable variant, add another 2016-10-05 14:43:23 +00:00
strconv strconv: strip \r in raw strings passed to Unquote 2016-10-17 18:34:02 +00:00
strings bytes, strings: fix regression in IndexRune 2016-10-26 23:02:27 +00:00
sync sync: throw, not panic, for unlock of unlocked mutex 2016-10-19 17:46:27 +00:00
syscall syscall: use name+(NN)FP on plan9/amd64 2016-10-25 22:13:35 +00:00
testing all: freeze net/rpc and reword the 'frozen' message in other frozen packages 2016-10-26 16:11:07 +00:00
text all: freeze net/rpc and reword the 'frozen' message in other frozen packages 2016-10-26 16:11:07 +00:00
time time: revise Timer comments for Stop, Reset 2016-10-18 12:55:24 +00:00
unicode unicode/utf8: optimize ValidRune 2016-10-26 23:02:52 +00:00
unsafe
vendor/golang_org/x vendor/golang_org/x/crypto/curve25519: update to f62085100e1abe3d5c9b3b8c9a38d50b71323f64 2016-10-21 21:33:30 +00:00
all.bash
all.bat
all.rc
androidtest.bash
bootstrap.bash
buildall.bash
clean.bash
clean.bat
clean.rc
cmp.bash
iostest.bash
make.bash cmd/dist, cmd/go: add environment variable override for pkg-config 2016-10-03 18:08:01 +00:00
make.bat
Make.dist
make.rc
naclmake.bash
nacltest.bash
race.bash
race.bat
run.bash
run.bat
run.rc