From cfb8b18e75faa1d0cec07268825db06679cd3946 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 30 Apr 2015 10:16:23 +0300 Subject: strings: use LastIndexByte in LastIndex Change-Id: I1add1b92f5c2688a99133d90bf9789d770fd9f05 Reviewed-on: https://go-review.googlesource.com/9503 Reviewed-by: Matthew Dempsky --- src/strings/strings.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'src/strings/strings.go') diff --git a/src/strings/strings.go b/src/strings/strings.go index 7b8a6b536b..567a3c5bfa 100644 --- a/src/strings/strings.go +++ b/src/strings/strings.go @@ -185,14 +185,7 @@ func LastIndex(s, sep string) int { case n == 0: return len(s) case n == 1: - // special case worth making fast - c := sep[0] - for i := len(s) - 1; i >= 0; i-- { - if s[i] == c { - return i - } - } - return -1 + return LastIndexByte(s, sep[0]) case n == len(s): if sep == s { return 0 -- cgit v1.3-5-g9baa