]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: use better splitting condition for string binary search
authorKeith Randall <khr@golang.org>
Sat, 25 Jun 2022 18:11:07 +0000 (11:11 -0700)
committerKeith Randall <khr@golang.org>
Wed, 31 Aug 2022 22:08:26 +0000 (22:08 +0000)
commit69aed4712d73c9c1b70be3e2e222eb55391e2fb0
tree07d66c7c2961f8d328bd6d0ebbda4cad43242763
parentaf7f067e0d7f92bcf4d0938d093725a0ac6366b1
cmd/compile: use better splitting condition for string binary search

Currently we use a full cmpstring to do the comparison for each
split in the binary search for a string switch.

Instead, split by comparing a single byte of the input string with a
constant. That will give us a much faster split (although it might be
not quite as good a split).

Fixes #53333

R=go1.20

Change-Id: I28c7209342314f367071e4aa1f2beb6ec9ff7123
Reviewed-on: https://go-review.googlesource.com/c/go/+/414894
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
src/cmd/compile/internal/walk/switch.go
test/codegen/switch.go