1
0
mirror of https://github.com/golang/go synced 2024-11-20 01:44:42 -07:00
go/src/bytes
Russ Cox 2a166c93a3 bytes, strings: restore O(1) behavior of IndexAny(s, "") and LastIndexAny(s, "")
CL 65851 (bytes) and CL 65910 (strings) “improve[d] readability”
by removing the special case that bypassed the whole function body
when chars == "". In doing so, yes, the function was unindented a
level, which is nice, but the runtime of that case went from O(1) to O(n)
where n = len(s).

I don't know if anyone's code depends on the O(1) behavior in this case,
but quite possibly someone's does.

This CL adds the special case back, with a comment to prevent future
deletions, and without reindenting each function body in full.

Change-Id: I5aba33922b304dd1b8657e6d51d6c937a7f95c81
Reviewed-on: https://go-review.googlesource.com/78112
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-11-15 21:26:05 +00:00
..
boundary_test.go bytes: reduce work in IndexNearPageBoundary test 2017-11-04 11:09:49 +00:00
buffer_test.go bytes: panic in ReadFrom with more information with negative Read counts 2017-10-06 06:49:40 +00:00
buffer.go bytes: panic in ReadFrom with more information with negative Read counts 2017-10-06 06:49:40 +00:00
bytes_amd64.go bytes,strings: in generic Index, use mix of IndexByte and Rabin-Karp 2017-11-15 17:35:09 +00:00
bytes_decl.go all: make copyright headers consistent with one space after period 2016-03-01 23:34:33 +00:00
bytes_generic.go bytes,strings: in generic Index, use mix of IndexByte and Rabin-Karp 2017-11-15 17:35:09 +00:00
bytes_s390x.go bytes,strings: in generic Index, use mix of IndexByte and Rabin-Karp 2017-11-15 17:35:09 +00:00
bytes_test.go bytes,strings: in generic Index, use mix of IndexByte and Rabin-Karp 2017-11-15 17:35:09 +00:00
bytes.go bytes, strings: restore O(1) behavior of IndexAny(s, "") and LastIndexAny(s, "") 2017-11-15 21:26:05 +00:00
compare_test.go all: single space after period. 2016-03-02 00:13:47 +00:00
example_test.go bytes, strings: restore O(1) behavior of IndexAny(s, "") and LastIndexAny(s, "") 2017-11-15 21:26:05 +00:00
export_test.go bytes: add optimized countByte for amd64 2017-03-21 20:25:17 +00:00
reader_test.go bytes: improve test readability 2017-09-20 13:41:03 +00:00
reader.go bytes: add documentation to reader methods 2017-09-21 18:57:04 +00:00