aboutsummaryrefslogtreecommitdiff
path: root/test/prove.go
diff options
context:
space:
mode:
authorIlya Tocar <ilya.tocar@intel.com>2017-03-28 15:30:31 -0500
committerIlya Tocar <ilya.tocar@intel.com>2017-04-07 15:40:25 +0000
commite4a500ce1490a5db709da5880f0121e5eeac73cd (patch)
tree99bc58f9a1d58b9f2824db56a55e575d857b6f66 /test/prove.go
parentd206af1e6c53df0c59d9466fe9c50415f9d8dcd5 (diff)
downloadgo-e4a500ce1490a5db709da5880f0121e5eeac73cd.tar.gz
go-e4a500ce1490a5db709da5880f0121e5eeac73cd.zip
cmd/compile/internal/gc: improve comparison with constant strings
Currently we expand comparison with small constant strings into len check and a sequence of byte comparisons. Generate 16/32/64-bit comparisons, instead of bytewise on 386 and amd64. Also increase limits on what is considered small constant string. Shaves ~30kb (0.5%) from go executable. This also updates test/prove.go to keep test case valid. Change-Id: I99ae8871a1d00c96363c6d03d0b890782fa7e1d9 Reviewed-on: https://go-review.googlesource.com/38776 Run-TryBot: Ilya Tocar <ilya.tocar@intel.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Diffstat (limited to 'test/prove.go')
-rw-r--r--test/prove.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/test/prove.go b/test/prove.go
index 5f4de604c6..e89ab3f8d8 100644
--- a/test/prove.go
+++ b/test/prove.go
@@ -250,7 +250,9 @@ func f9(a, b bool) int {
func f10(a string) int {
n := len(a)
- if a[:n>>1] == "aaaaaaaaaaaaaa" {
+ // We optimize comparisons with small constant strings (see cmd/compile/internal/gc/walk.go),
+ // so this string literal must be long.
+ if a[:n>>1] == "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" {
return 0
}
return 1