aboutsummaryrefslogtreecommitdiff
path: root/src/strings/strings.go
AgeCommit message (Collapse)Author
2016-09-07strings: make IndexRune fasterHiroshi Ioka
re-implement IndexRune by Index which is well optimized to get performance gain. name old time/op new time/op delta IndexRune-4 30.2ns ± 1% 28.3ns ± 1% -6.22% (p=0.000 n=20+19) IndexRuneLongString-4 156ns ± 1% 49ns ± 1% -68.72% (p=0.000 n=19+19) IndexRuneFastPath-4 10.6ns ± 2% 10.0ns ± 1% -6.30% (p=0.000 n=18+18) Change-Id: Ie663b8f7860ca51892dd4be182fca3caa5f8ae61 Reviewed-on: https://go-review.googlesource.com/28546 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-16strings: add special cases for Join of 2 and 3 stringsBrad Fitzpatrick
We already had special cases for 0 and 1. Add 2 and 3 for now too. To be removed if the compiler is improved later (#6714). This halves the number of allocations and total bytes allocated via common filepath.Join calls, improving filepath.Walk performance. Noticed as part of investigating filepath.Walk in #16399. Change-Id: If7b1bb85606d4720f3ebdf8de7b1e12ad165079d Reviewed-on: https://go-review.googlesource.com/25005 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-13strings: improve explode and correct commentMartin Möhrmann
Merges explodetests into splittests which already contain some of the tests that cover explode. Adds a test to cover the utf8.RuneError branch in explode. name old time/op new time/op delta Split1-2 14.9ms ± 0% 14.2ms ± 0% -4.06% (p=0.000 n=47+49) Change-Id: I00f796bd2edab70e926ea9e65439d820c6a28254 Reviewed-on: https://go-review.googlesource.com/21609 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-02all: single space after period.Brad Fitzpatrick
The tree's pretty inconsistent about single space vs double space after a period in documentation. Make it consistently a single space, per earlier decisions. This means contributors won't be confused by misleading precedence. This CL doesn't use go/doc to parse. It only addresses // comments. It was generated with: $ perl -i -npe 's,^(\s*// .+[a-z]\.) +([A-Z]),$1 $2,' $(git grep -l -E '^\s*//(.+\.) +([A-Z])') $ go test go/doc -update Change-Id: Iccdb99c37c797ef1f804a94b22ba5ee4b500c4f7 Reviewed-on: https://go-review.googlesource.com/20022 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Dave Day <djd@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-03strings: add asm version of Index() for short strings on amd64Ilya Tocar
Currently we have special case for 1-byte strings, This extends this to strings shorter than 32 bytes on amd64. Results (broadwell): name old time/op new time/op delta IndexRune-4 57.4ns ± 0% 57.5ns ± 0% +0.10% (p=0.000 n=20+19) IndexRuneFastPath-4 20.4ns ± 0% 20.4ns ± 0% ~ (all samples are equal) Index-4 21.0ns ± 0% 21.8ns ± 0% +3.81% (p=0.000 n=20+20) LastIndex-4 7.07ns ± 1% 6.98ns ± 0% -1.21% (p=0.000 n=20+16) IndexByte-4 18.3ns ± 0% 18.3ns ± 0% ~ (all samples are equal) IndexHard1-4 1.46ms ± 0% 0.39ms ± 0% -73.06% (p=0.000 n=16+16) IndexHard2-4 1.46ms ± 0% 0.30ms ± 0% -79.55% (p=0.000 n=18+18) IndexHard3-4 1.46ms ± 0% 0.66ms ± 0% -54.68% (p=0.000 n=19+19) LastIndexHard1-4 1.46ms ± 0% 1.46ms ± 0% -0.01% (p=0.036 n=18+20) LastIndexHard2-4 1.46ms ± 0% 1.46ms ± 0% ~ (p=0.588 n=19+19) LastIndexHard3-4 1.46ms ± 0% 1.46ms ± 0% ~ (p=0.283 n=17+20) IndexTorture-4 11.1µs ± 0% 11.1µs ± 0% +0.01% (p=0.000 n=18+17) Change-Id: I892781549f558f698be4e41f9f568e3d0611efb5 Reviewed-on: https://go-review.googlesource.com/16430 Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
2015-07-12all: link to https for golang subdomains tooBrad Fitzpatrick
The previous commit (git 2ae77376) just did golang.org. This one includes golang.org subdomains like blog, play, and build. Change-Id: I4469f7b307ae2a12ea89323422044e604c5133ae Reviewed-on: https://go-review.googlesource.com/12071 Reviewed-by: Rob Pike <r@golang.org>
2015-06-03strings: mention UTF-8 in the package comment.Rob Pike
Also add a reference to the strings blog post. Fixes #11045. Change-Id: Ic0a8908cbd7b51a36d104849fa0e8abfd54de2b9 Reviewed-on: https://go-review.googlesource.com/10662 Reviewed-by: Andrew Gerrand <adg@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-30strings: use LastIndexByte in LastIndexDmitry Vyukov
Change-Id: I1add1b92f5c2688a99133d90bf9789d770fd9f05 Reviewed-on: https://go-review.googlesource.com/9503 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2015-04-30bytes, strings: add LastIndexByteDmitry Vyukov
Currently the packages have the following index functions: func Index(s, sep []byte) int func IndexAny(s []byte, chars string) int func IndexByte(s []byte, c byte) int func IndexFunc(s []byte, f func(r rune) bool) int func IndexRune(s []byte, r rune) int func LastIndex(s, sep []byte) int func LastIndexAny(s []byte, chars string) int func LastIndexFunc(s []byte, f func(r rune) bool) int Searching for the last occurrence of a byte is quite common for string parsing algorithms (e.g. find the last paren on a line). Also addition of LastIndexByte makes the set more orthogonal. Change-Id: Ida168849acacf8e78dd70c1354bef9eac5effafe Reviewed-on: https://go-review.googlesource.com/9500 Reviewed-by: Rob Pike <r@golang.org>
2015-03-20bytes, os/exec, strings: fix a few BUG commentsareski
Regular expression noteMarker requires the definition of a (who) section when reading note from a sequence of comments. Change-Id: I9635de9b86f00d20ec108097fee4d4a8f76237b2 Reviewed-on: https://go-review.googlesource.com/1952 Reviewed-by: Russ Cox <rsc@golang.org>
2015-03-18all: use "reports whether" in place of "returns true if(f)"Josh Bleecher Snyder
Comment changes only. Change-Id: I56848814564c4aa0988b451df18bebdfc88d6d94 Reviewed-on: https://go-review.googlesource.com/7721 Reviewed-by: Rob Pike <r@golang.org>
2015-01-22bytes, strings: improve documentation for Count functionsRobert Griesemer
Fixes #9659. Change-Id: If364d5984a0c9a48858ae524b1560f633e621826 Reviewed-on: https://go-review.googlesource.com/3181 Reviewed-by: Rob Pike <r@golang.org>
2014-10-06strings: use fast path for IndexRuneBrad Fitzpatrick
Noticed while reviewing https://golang.org/cl/147690043/ I'd never seen anybody use IndexRune before, and unsurprisingly it doesn't use the other fast paths in the strings/bytes packages. IndexByte uses assembly. Also, less code this way. LGTM=r R=r CC=golang-codereviews https://golang.org/cl/147700043
2014-09-18bytes, strings: document that FieldsFunc f must not be statefulRuss Cox
Fixes #8738. LGTM=adg R=golang-codereviews, adg CC=golang-codereviews https://golang.org/cl/143260045
2014-09-08build: move package sources from src/pkg to srcRuss Cox
Preparation was in CL 134570043. This CL contains only the effect of 'hg mv src/pkg/* src'. For more about the move, see golang.org/s/go14nopkg.