diff options
author | Marvin Stenger <marvin.stenger94@gmail.com> | 2017-09-25 15:47:44 +0200 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2017-09-27 00:54:24 +0000 |
commit | d2826d3e068f096f4b5371175afb7e5d8c4aa73c (patch) | |
tree | e252245e001e359351b9a06891cadf6d725231b9 /src/cmd/fix | |
parent | e61c5e2f2044c7bc606ebdfbd0187598b90c50e5 (diff) | |
download | go-git-d2826d3e068f096f4b5371175afb7e5d8c4aa73c.tar.gz |
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/cmd/fix')
-rw-r--r-- | src/cmd/fix/fix.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/cmd/fix/fix.go b/src/cmd/fix/fix.go index cdc3c839d3..f12d1c7fe0 100644 --- a/src/cmd/fix/fix.go +++ b/src/cmd/fix/fix.go @@ -719,7 +719,7 @@ func usesImport(f *ast.File, path string) (used bool) { case "<nil>": // If the package name is not explicitly specified, // make an educated guess. This is not guaranteed to be correct. - lastSlash := strings.LastIndex(path, "/") + lastSlash := strings.LastIndexByte(path, '/') if lastSlash == -1 { name = path } else { |