diff options
Diffstat (limited to 'src/bytes')
| -rw-r--r-- | src/bytes/bytes.go | 9 | ||||
| -rw-r--r-- | src/bytes/bytes_test.go | 16 | ||||
| -rw-r--r-- | src/bytes/export_test.go | 8 |
3 files changed, 11 insertions, 22 deletions
diff --git a/src/bytes/bytes.go b/src/bytes/bytes.go index 9576350bf6..787ea86f00 100644 --- a/src/bytes/bytes.go +++ b/src/bytes/bytes.go @@ -98,15 +98,6 @@ func IndexByte(b []byte, c byte) int { return bytealg.IndexByte(b, c) } -func indexBytePortable(s []byte, c byte) int { - for i, b := range s { - if b == c { - return i - } - } - return -1 -} - // LastIndex returns the index of the last instance of sep in s, or -1 if sep is not present in s. func LastIndex(s, sep []byte) int { n := len(sep) diff --git a/src/bytes/bytes_test.go b/src/bytes/bytes_test.go index 891aef2c8b..07280464d2 100644 --- a/src/bytes/bytes_test.go +++ b/src/bytes/bytes_test.go @@ -323,10 +323,6 @@ func TestIndexByte(t *testing.T) { if pos != tt.i { t.Errorf(`IndexByte(%q, '%c') = %v`, tt.a, b, pos) } - posp := IndexBytePortable(a, b) - if posp != tt.i { - t.Errorf(`indexBytePortable(%q, '%c') = %v`, tt.a, b, posp) - } } } @@ -617,8 +613,18 @@ func BenchmarkIndexByte(b *testing.B) { benchBytes(b, indexSizes, bmIndexByte(IndexByte)) } +// indexBytePortable use as the baseline for performance comparisons. +func indexBytePortable(s []byte, c byte) int { + for i, b := range s { + if b == c { + return i + } + } + return -1 +} + func BenchmarkIndexBytePortable(b *testing.B) { - benchBytes(b, indexSizes, bmIndexByte(IndexBytePortable)) + benchBytes(b, indexSizes, bmIndexByte(indexBytePortable)) } func bmIndexByte(index func([]byte, byte) int) func(b *testing.B, n int) { diff --git a/src/bytes/export_test.go b/src/bytes/export_test.go deleted file mode 100644 index b65428d9ce..0000000000 --- a/src/bytes/export_test.go +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package bytes - -// Export func for testing -var IndexBytePortable = indexBytePortable |
