| Age | Commit message (Collapse) | Author |
|
««« CL 16880043 / 0eb6508d3e88
strings: fix Replacer bug with prefix matches
singleStringReplacer had a bug where if a string was replaced
at the beginning and no output had yet been produced into the
temp buffer before matching ended, an invalid nil check (used
as a proxy for having matched anything) meant it always
returned its input.
Fixes #6659
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/16880043
»»»
R=golang-dev
CC=golang-dev
https://golang.org/cl/20570044
|
|
R=golang-dev, dave, bradfitz, adg
CC=golang-dev
https://golang.org/cl/13249043
|
|
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12541050
|
|
Like existing Index, IndexRune, IndexHardN, etc.
R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/12486044
|
|
Fixes #3751
R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/12483043
|
|
I always forget which package has it.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12214044
|
|
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/7856048
|
|
Avoids printing it every time we ask a question about the package from
the command line.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7789048
|
|
BenchmarkSplit1 77984460 24131380 -69.06%
R=golang-dev, rsc, minux.ma, dave, extemporalgenome
CC=golang-dev
https://golang.org/cl/7458043
|
|
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7413045
|
|
Add a new, simple interface for scanning (probably textual) data,
based on a new type called Scanner. It does its own internal buffering,
so should be plausibly efficient even without injecting a bufio.Reader.
The format of the input is defined by a "split function", by default
splitting into lines. Other implemented split functions include single
bytes, single runes, and space-separated words.
Here's the loop to scan stdin as a file of lines:
s := bufio.NewScanner(os.Stdin)
for s.Scan() {
fmt.Printf("%s\n", s.Bytes())
}
if s.Err() != nil {
log.Fatal(s.Err())
}
While we're dealing with spaces, define what space means to strings.Fields.
Fixes #4802.
R=adg, rogpeppe, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/7322088
|
|
Slightly better benchmarks for when string and separator are equivalent and also less branching in inner loops.
benchmark old ns/op new ns/op delta
BenchmarkGenericNoMatch 3430 3442 +0.35%
BenchmarkGenericMatch1 23590 22855 -3.12%
BenchmarkGenericMatch2 108031 105025 -2.78%
BenchmarkSingleMaxSkipping 2969 2704 -8.93%
BenchmarkSingleLongSuffixFail 2826 2572 -8.99%
BenchmarkSingleMatch 205268 197832 -3.62%
BenchmarkByteByteNoMatch 987 921 -6.69%
BenchmarkByteByteMatch 2014 1749 -13.16%
BenchmarkByteStringMatch 3083 3050 -1.07%
BenchmarkHTMLEscapeNew 922 915 -0.76%
BenchmarkHTMLEscapeOld 1654 1570 -5.08%
BenchmarkByteByteReplaces 11897 11556 -2.87%
BenchmarkByteByteMap 4485 4255 -5.13%
BenchmarkIndexRune 174 121 -30.46%
BenchmarkIndexRuneFastPath 41 41 -0.24%
BenchmarkIndex 45 44 -0.22%
BenchmarkMapNoChanges 433 431 -0.46%
BenchmarkIndexHard1 4015336 3316490 -17.40%
BenchmarkIndexHard2 3976254 3395627 -14.60%
BenchmarkIndexHard3 3973158 3378329 -14.97%
BenchmarkCountHard1 4403549 3448512 -21.69%
BenchmarkCountHard2 4387437 3413059 -22.21%
BenchmarkCountHard3 4403891 3382661 -23.19%
BenchmarkIndexTorture 28354 25864 -8.78%
BenchmarkCountTorture 29625 27463 -7.30%
BenchmarkFields 38752040 39169840 +1.08%
BenchmarkFieldsFunc 38797765 38888060 +0.23%
benchmark old MB/s new MB/s speedup
BenchmarkSingleMaxSkipping 3367.07 3697.62 1.10x
BenchmarkSingleLongSuffixFail 354.51 389.47 1.10x
BenchmarkSingleMatch 73.07 75.82 1.04x
BenchmarkFields 27.06 26.77 0.99x
BenchmarkFieldsFunc 27.03 26.96 1.00x
R=dave, fullung, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/7350045
|
|
The O(n+m) complexity is obtained probabilistically
by using Rabin-Karp algorithm, which provides the needed complexity
unless exceptional collisions occur, without memory allocation.
benchmark old ns/op new ns/op delta
BenchmarkIndexHard1 6532331 4045886 -38.06%
BenchmarkIndexHard2 8178173 4038975 -50.61%
BenchmarkIndexHard3 6973687 4042591 -42.03%
BenchmarkCountHard1 6270864 4071090 -35.08%
BenchmarkCountHard2 7838039 4072853 -48.04%
BenchmarkCountHard3 6697828 4071964 -39.20%
BenchmarkIndexTorture 2730546 28934 -98.94%
BenchmarkCountTorture 2729622 29064 -98.94%
Fixes #4600.
R=rsc, donovanhide, remyoudompheng
CC=golang-dev
https://golang.org/cl/7314095
|
|
Everybody either gets confused and thinks this is
TrimLeft/TrimRight or does this by hand which gets
repetitive looking.
R=rsc, kevlar
CC=golang-dev
https://golang.org/cl/7239044
|
|
Fixes #4421
R=golang-dev, dave, minux.ma, mchaten, rsc
CC=golang-dev
https://golang.org/cl/6855083
|
|
Remove trailing whitespace in comments.
No other changes.
R=r
CC=golang-dev
https://golang.org/cl/6815053
|
|
Fixes #4031.
R=golang-dev, bradfitz, remyoudompheng, r, dave
CC=golang-dev
https://golang.org/cl/6632046
|
|
The string searching is implemented separately so other functions
may make use of it in the future.
benchmark old ns/op new ns/op delta
BenchmarkSingleMaxSkipping 125889 2474 -98.03%
BenchmarkSingleLongSuffixFail 16252 1996 -87.72%
BenchmarkSingleMatch 260793 136266 -47.75%
benchmark old MB/s new MB/s speedup
BenchmarkSingleMaxSkipping 79.43 4041.57 50.88x
BenchmarkSingleLongSuffixFail 61.65 501.81 8.14x
BenchmarkSingleMatch 57.52 110.08 1.91x
R=nigeltao
CC=golang-dev
https://golang.org/cl/6545049
|
|
The performance changes will be a few different CLs.
Start with benchmarks as a baseline.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6537043
|
|
This also fixes the semantics of some corner cases with the empty
match. TODOs for genericReplacer in the tests are fixed.
benchmark old ns/op new ns/op delta
BenchmarkGenericNoMatch 71395 3132 -95.61%
BenchmarkGenericMatch1 75610 20280 -73.18%
BenchmarkGenericMatch2 837995 86725 -89.65%
R=nigeltao, rsc
CC=golang-dev
https://golang.org/cl/6492076
|
|
when oldi == oldj.
Benchmark numbers show no substantial change.
R=eric.d.eisner, rogpeppe
CC=golang-dev
https://golang.org/cl/6496104
|
|
This verifies existing behavior. Some replacements are arguably wrong
(these are marked with TODO) but changing behavior is left for a
follow-up CL.
Also fix that BenchmarkGenericMatch wasn't actually matching anything.
R=rsc, eric.d.eisner
CC=bradfitz, golang-dev
https://golang.org/cl/6488110
|
|
Comment groups must end at the end of a line (or the
next non-comment token) if the group started on a line
with non-comment tokens.
This is important for correct computation of "lead"
and "line" comments (Doc and Comment fields in AST nodes).
Without this fix, the "line" comment for F1 in the
following example:
type T struct {
F1 int // comment1
// comment2
F2 int
}
is "// comment1// comment2" rather than just "// comment1".
This bug was present from Day 1 but only visible when
looking at export-filtered ASTs where only comments
associated with AST nodes are printed, and only in rare
cases (e.g, in the case above, if F2 where not exported,
godoc would show "// comment2" anyway because it was
considered part of the "line" comment for F1).
The bug fix is very small (parser.go). The bulk of the
changes are additional test cases (parser_test.go).
The fix exposed a caching bug in go/printer via one of the
existing tests, hence the changes to printer.go.
As an aside, the fix removes the the need for empty lines
before an "// Output" comment for some special cases of
code examples (e.g.: src/pkg/strings/example_test.go, Count
example).
No impact on gofmt formatting of src, misc.
Fixes #3139.
R=rsc
CC=golang-dev
https://golang.org/cl/6209080
|
|
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5729065
|
|
Thanks to dr.volker.dobler for tracking this down.
Filed a long-term issue (3142) which may eventually
resolve this problem w/o the need for a manual fix.
R=iant
CC=golang-dev
https://golang.org/cl/5698078
|
|
go/doc: move Examples to go/ast
cmd/go: use go/doc to read examples
src/pkg: update examples to use new convention
This is to make whole file examples more readable. When presented as a
complete function, preceding an Example with its output is confusing.
The new convention is to put the expected output in the final comment
of the example, preceded by the string "output:" (case insensitive).
An idiomatic example looks like this:
// This example demonstrates Foo by doing bar and quux.
func ExampleFoo() {
// example body that does bar and quux
// Output:
// example output
}
R=rsc, gri
CC=golang-dev
https://golang.org/cl/5673053
|
|
R=r, bradfitz
CC=golang-dev, rogpeppe
https://golang.org/cl/5673049
|
|
R=golang-dev, adg, bradfitz, r
CC=golang-dev
https://golang.org/cl/5675053
|
|
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5645092
|
|
Fixes #2957.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5653053
|
|
strings.Reader is already stateful and read-only.
This permits a *Reader with http.ServeContent.
R=golang-dev, r, rsc, rsc
CC=golang-dev
https://golang.org/cl/5639068
|
|
R=golang-dev, rsc, r
CC=golang-dev
https://golang.org/cl/5629043
|
|
Consequently, remove many package Makefiles,
and shorten the few that remain.
gomake becomes 'go tool make'.
Turn off test phases of run.bash that do not work,
flagged with $BROKEN. Future CLs will restore these,
but this seemed like a big enough CL already.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5601057
|
|
Lots of panics go away.
Also fix a name error in html/template.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5498045
|
|
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5448091
|
|
R=rsc, gri
CC=golang-dev
https://golang.org/cl/5445044
|
|
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5430046
|
|
R=gri, r, bradfitz
CC=golang-dev
https://golang.org/cl/5371074
|
|
R=rsc
CC=golang-dev
https://golang.org/cl/5345045
|
|
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5334050
|
|
R=golang-dev, bsiegert, iant
CC=golang-dev
https://golang.org/cl/5294074
|
|
Various rune-based APIs change.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5306044
|
|
This implements a replacer for when all old strings are single
bytes, but new values are not.
BenchmarkHTMLEscapeNew 1000000 1090 ns/op
BenchmarkHTMLEscapeOld 1000000 2049 ns/op
R=rsc
CC=golang-dev
https://golang.org/cl/5176043
|
|
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
|
|
This is just a new API to do many replacements at once.
While the point of this API is to be faster than doing replacements one
at a time, the implementation in this CL has the optimizations removed
and may actually be slower.
Future CLs will bring back & add optimizations.
R=r, rsc, rogpeppe
CC=golang-dev
https://golang.org/cl/5081042
|
|
R=golang-dev, r, r
CC=golang-dev
https://golang.org/cl/5123047
|
|
Case-insensitive strcmp without using ToLower.
(Using ToLower is not always correct, and it allocates.)
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5143044
|
|
manual changes in src/pkg/go/printer, src/cmd/gofix/signal_test.go
(cd src/cmd/gofix/testdata; gofmt -w *.in *.out)
(cd src/pkg/go/printer; gotest -update)
gofmt -w misc src
runs all tests
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4715041
|
|
Change the signature of Split to have no count,
assuming a full split, and rename the existing
Split with a count to SplitN.
Do the same to package bytes.
Add a gofix module.
R=adg, dsymonds, alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/4661051
|
|
This is a core API change.
1) gofix misc src
2) Manual adjustments to the following files under src/pkg:
gob/decode.go
rpc/client.go
os/error.go
io/io.go
bufio/bufio.go
http/request.go
websocket/client.go
as well as:
src/cmd/gofix/testdata/*.go.in (reverted)
test/fixedbugs/bug243.go
3) Implemented gofix patch (oserrorstring.go) and test case (oserrorstring_test.go)
Compiles and runs all tests.
R=r, rsc, gri
CC=golang-dev
https://golang.org/cl/4607052
|