From 8039ca76a5705ae5052b20cee64110c32545c4fc Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 24 Mar 2011 23:46:17 +0000 Subject: Update to current version of Go library. From-SVN: r171427 --- libgo/go/strings/strings.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'libgo/go/strings/strings.go') diff --git a/libgo/go/strings/strings.go b/libgo/go/strings/strings.go index 98a0d57..5f009e5 100644 --- a/libgo/go/strings/strings.go +++ b/libgo/go/strings/strings.go @@ -119,9 +119,19 @@ func LastIndex(s, sep string) int { // IndexRune returns the index of the first instance of the Unicode code point // rune, or -1 if rune is not present in s. func IndexRune(s string, rune int) int { - for i, c := range s { - if c == rune { - return i + switch { + case rune < 0x80: + b := byte(rune) + for i := 0; i < len(s); i++ { + if s[i] == b { + return i + } + } + default: + for i, c := range s { + if c == rune { + return i + } } } return -1 -- cgit v1.1