aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authorMarvin Stenger <marvin.stenger94@gmail.com>2017-09-25 15:47:44 +0200
committerIan Lance Taylor <iant@golang.org>2017-09-27 00:54:24 +0000
commitd2826d3e068f096f4b5371175afb7e5d8c4aa73c (patch)
treee252245e001e359351b9a06891cadf6d725231b9 /src/testing
parente61c5e2f2044c7bc606ebdfbd0187598b90c50e5 (diff)
downloadgo-d2826d3e068f096f4b5371175afb7e5d8c4aa73c.tar.xz
all: prefer strings.LastIndexByte over strings.LastIndex
strings.LastIndexByte was introduced in go1.5 and it can be used effectively wherever the second argument to strings.LastIndex is exactly one byte long. This avoids generating unnecessary string symbols and saves a few calls to strings.LastIndex. Change-Id: I7b5679d616197b055cffe6882a8675d24a98b574 Reviewed-on: https://go-review.googlesource.com/66372 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/testing.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/testing/testing.go b/src/testing/testing.go
index a170cd0fd9..d5c045f253 100644
--- a/src/testing/testing.go
+++ b/src/testing/testing.go
@@ -360,7 +360,7 @@ func (c *common) decorate(s string) string {
_, file, line, ok := runtime.Caller(skip)
if ok {
// Truncate file name at last file name separator.
- if index := strings.LastIndex(file, "/"); index >= 0 {
+ if index := strings.LastIndexByte(file, '/'); index >= 0 {
file = file[index+1:]
} else if index = strings.LastIndex(file, "\\"); index >= 0 {
file = file[index+1:]