1
0
mirror of https://github.com/golang/go synced 2024-10-04 10:21:21 -06:00
go/src/pkg/strings/export_test.go
Brad Fitzpatrick f75ff01f44 strings: implement a faster byte->byte Replacer
When all old & new string values are single bytes,
byteReplacer is now used, instead of the generic
algorithm.

BenchmarkGenericMatch       10000  102519 ns/op
BenchmarkByteByteMatch    1000000    2178 ns/op

fast path, when nothing matches:
BenchmarkByteByteNoMatch  1000000    1109 ns/op

comparisons to multiple Replace calls:
BenchmarkByteByteReplaces  100000   16164 ns/op

comparison to strings.Map:
BenchmarkByteByteMap       500000    5454 ns/op

R=rsc
CC=golang-dev
https://golang.org/cl/5175050
2011-10-03 13:12:01 -07:00

10 lines
235 B
Go

// Copyright 2011 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 strings
func (r *Replacer) Replacer() interface{} {
return r.r
}