Rob Pike
464257eeff
bytes,string: move the BUG to the comment of the function it's about
...
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
2013-03-15 17:08:07 -07:00
Shenghou Ma
691e5e3b01
bytes: annotate assembly functions with //go:noescape
...
R=golang-dev, agl, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/7299064
2013-02-10 00:08:30 +08:00
Brad Fitzpatrick
30a9957aac
bytes: minor optimization to lastIndexFunc
...
Before and after:
BenchmarkTrimSpace 20000000 81.3 ns/op
BenchmarkTrimSpace 50000000 58.0 ns/op
(most whitespace trimming is ASCII whitespace)
Same optimization appeared a handful of other places
in this file, but not here.
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/7305063
2013-02-07 16:00:06 -08:00
Brad Fitzpatrick
e515d80d5d
bytes, strings: add TrimPrefix and TrimSuffix
...
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
2013-02-01 08:41:25 -08:00
Stéphane Travostino
53e342f648
bytes: fix UnreadByte failure after ReadBytes
...
Fixes #4583 .
R=golang-dev, minux.ma, bradfitz, rsc, dave
CC=golang-dev
https://golang.org/cl/6976050
2013-01-11 17:02:21 +11:00
Matthew Dempsky
2e24a737c5
bytes: Fix missing godoc punctuation.
...
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7067047
2013-01-06 22:44:04 -05:00
Matthew Dempsky
8cf45909b5
bytes: Change Compare example to be consistent with sort.Search's.
...
R=rsc, adg
CC=golang-dev
https://golang.org/cl/7057049
2013-01-06 22:43:32 -05:00
Nigel Tao
c753404886
bytes: fix docs: s/array/slice/.
...
R=rsc, mdempsky, dave
CC=golang-dev
https://golang.org/cl/7028051
2013-01-07 10:48:06 +11:00
Matthew Dempsky
56961274bb
bytes: Examples recommending bytes.Compare(a, b) rel_op 0 to test a rel_op b.
...
R=golang-dev, minux.ma, rsc, adg
CC=golang-dev
https://golang.org/cl/7042045
2013-01-07 09:59:37 +11:00
Rémy Oudompheng
b1c4a8efa9
bytes: avoid duplicate malloc/copy in Buffer.ReadString
...
Twice faster and twice less garbage.
R=golang-dev, dave, daniel.morsing, bradfitz
CC=golang-dev
https://golang.org/cl/6849128
2012-12-03 14:04:18 +01:00
Brad Fitzpatrick
c8fa7dcc25
bytes, strings: fix Reader WriteTo return value on 0 bytes copied
...
Fixes #4421
R=golang-dev, dave, minux.ma, mchaten, rsc
CC=golang-dev
https://golang.org/cl/6855083
2012-11-25 09:04:13 -08:00
Robert Griesemer
465b9c35e5
gofmt: apply gofmt -w src misc
...
Remove trailing whitespace in comments.
No other changes.
R=r
CC=golang-dev
https://golang.org/cl/6815053
2012-10-30 13:38:01 -07:00
Evan Shaw
eae25d430d
bytes, strings: add (*Reader).WriteTo
...
Fixes #4031 .
R=golang-dev, bradfitz, remyoudompheng, r, dave
CC=golang-dev
https://golang.org/cl/6632046
2012-10-12 14:43:50 +11:00
Andrew Gerrand
749a445ba0
bytes: fix tests and fix build
...
R=golang-dev, edsrzf
CC=golang-dev
https://golang.org/cl/6633051
2012-10-10 11:59:39 +11:00
Andrew Gerrand
e7c222cada
bytes: make examples work in playground
...
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6633050
2012-10-10 11:15:41 +11:00
Russ Cox
10ea6519e4
build: make int 64 bits on amd64
...
The assembly offsets were converted mechanically using
code.google.com/p/rsc/cmd/asmlint. The instruction
changes were done by hand.
Fixes #2188 .
R=iant, r, bradfitz, remyoudompheng
CC=golang-dev
https://golang.org/cl/6550058
2012-09-24 20:57:01 -04:00
Russ Cox
8572950383
all: match asm variable names to Go func declarations
...
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6548046
2012-09-21 00:35:56 -04:00
Russ Cox
0e60019a42
bytes, strings: add Fields benchmarks
...
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
2012-09-18 15:02:08 -04:00
Gustavo Niemeyer
c0efcac6a9
bytes: make Join return a new buffer on len(a) == 1
...
Fixes #3844 .
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6432054
2012-07-20 16:04:22 -03:00
Rob Pike
1255a6302d
bytes.Buffer: export the Grow method
...
Allows a client to pre-allocate buffer space that is known to be necessary,
avoiding expensive reallocations.
R=gri, gri, adg
CC=golang-dev
https://golang.org/cl/6392061
2012-07-12 20:52:19 -07:00
Marcel van Lohuizen
9c9754409d
bytes: fixed typo.
...
R=r
CC=golang-dev
https://golang.org/cl/6301096
2012-06-18 17:43:05 -07:00
Dave Cheney
d472d3faf1
bytes: add assembly version of Equal for ARM
...
BenchmarkEqual32 662 159 -75.98%
BenchmarkEqual4K 76545 13719 -82.08%
BenchmarkEqual4M 90136700 23588870 -73.83%
BenchmarkEqual64M 2147483647 1419616000 -42.63%
BenchmarkEqual32 48.32 201.15 4.16x
BenchmarkEqual4K 53.51 298.56 5.58x
BenchmarkEqual4M 46.53 177.81 3.82x
BenchmarkEqual64M 27.12 47.27 1.74x
R=golang-dev, qyzhai, minux.ma, rsc, iant, nigeltao
CC=golang-dev
https://golang.org/cl/6118049
2012-05-02 12:10:24 +10:00
Dave Cheney
0681b13437
bytes: add assembly version of IndexByte for ARM
...
benchmark old ns/op new ns/op delta
BenchmarkIndexByte32 459 126 -72.55%
BenchmarkIndexByte4K 52404 10939 -79.13%
BenchmarkIndexByte4M 54470800 11177370 -79.48%
BenchmarkIndexByte64M 1010803000 178860500 -82.31%
benchmark old MB/s new MB/s speedup
BenchmarkIndexByte32 69.58 252.63 3.63x
BenchmarkIndexByte4K 78.16 374.42 4.79x
BenchmarkIndexByte4M 77.00 375.25 4.87x
BenchmarkIndexByte64M 66.39 375.20 5.65x
R=rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6106044
2012-04-25 13:18:31 +10:00
David Symonds
85f2d18a72
bytes: document Compare/Equal semantics for nil arguments, and add tests.
...
R=golang-dev, bradfitz, r, r
CC=golang-dev
https://golang.org/cl/5676090
2012-02-18 17:39:40 +11:00
Andrew Gerrand
11e113db57
godoc: make example code more readable with new comment convention
...
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
2012-02-16 11:50:28 +11:00
Brad Fitzpatrick
7127b6fddc
bytes,strings: make *Reader implement io.ReaderAt
...
R=golang-dev, adg, bradfitz, r
CC=golang-dev
https://golang.org/cl/5675053
2012-02-15 12:58:00 +11:00
Brad Fitzpatrick
977e8d145b
bytes: add Reader
...
copy of strings/reader{,_test}.go with
a few s/string/[]byte/
Fixes #2861
R=adg, rsc, r
CC=golang-dev
https://golang.org/cl/5666044
2012-02-15 11:06:16 +11:00
Rob Pike
c59dc485cd
bytes.Buffer: return error in WriteTo if buffer is not drained
...
R=rsc
CC=golang-dev
https://golang.org/cl/5642065
2012-02-09 08:58:40 +11:00
Rob Pike
0a75a79cc0
bytes: API tweaks
...
- fix documentation for NewBuffer and NewBufferString
- document and implement behavior of Truncate on invalid lengths
Fixes #2837 .
R=rsc, adg
CC=golang-dev
https://golang.org/cl/5637044
2012-02-06 15:29:21 +11:00
Russ Cox
2050a9e478
build: remove Make.pkg, Make.tool
...
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
2012-01-30 23:43:46 -05:00
Rob Pike
87079cc14c
bytes: delete the test for huge buffers
...
It takes too much memory to be reliable and causes
trouble on 32-bit machines.
Sigh.
Fixes #2756 .
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5567043
2012-01-22 09:25:47 -08:00
Robert Griesemer
e17afa4d0c
bytes.Buffer: remove dead code, complete documentation
...
R=r, dave, r
CC=golang-dev
https://golang.org/cl/5533086
2012-01-21 21:31:21 -08:00
Rob Pike
b0d2713b77
bytes.Buffer: restore panic on out-of-memory
...
Make the panic detectable, and use that in ioutil.ReadFile to
give an error if the file is too big.
R=golang-dev, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/5563045
2012-01-21 09:46:59 -08:00
Robert Griesemer
35ba05ee28
bytes: simplified logic
...
Also: Avoid potential crash due to reslicing of nil buffer.
R=r
CC=golang-dev
https://golang.org/cl/5556075
2012-01-20 15:39:14 -08:00
Rob Pike
696bf79350
bytes.Buffer: turn buffer size overflows into errors
...
Fixes #2743 .
R=golang-dev, gri, r
CC=golang-dev
https://golang.org/cl/5556072
2012-01-20 13:51:49 -08:00
Olivier Duperray
dcc5fe1e20
pkg/bytes: add the usual copyright notice to example_test.go
...
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5553050
2012-01-18 09:40:50 -08:00
Brad Fitzpatrick
87ceb0cec7
bytes: make Write and WriteString code look the same
...
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5540056
2012-01-13 11:48:57 -08:00
Rob Pike
6a88f1c4cb
bytes.Buffer: read of 0 bytes at EOF shouldn't be an EOF
...
This corner case arose doing an RPC with a empty-slice payload. Ouch.
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/5505073
2011-12-26 23:49:24 -08:00
Rob Pike
6b772462e4
panics: use the new facilities of testing.B instead
...
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
2011-12-20 10:36:25 -08:00
Andrew Gerrand
9834a25d33
testing: trim spaces before comparing example output
...
bytes: add two Buffer examples
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5490048
2011-12-16 09:43:58 +11:00
Robert Griesemer
9f65e99ad4
go/printer, gofmt: don't write too many newlines
...
In some rare cases, gofmt would accept more than the maximum
number of empty lines (1) between source code snippets.
The actual change is in printer.go, lines 773-775; the rest
is some minor restructuring.
Applied gofmt -w src misc .
Fixes #2387 .
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5496047
2011-12-15 13:51:47 -08:00
Russ Cox
a250f37cbc
update tree for new default type rule
...
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5448091
2011-12-08 22:08:03 -05:00
Russ Cox
1278c6c055
bytes: lost edit from earlier CL
...
R=iant
CC=golang-dev
https://golang.org/cl/5450125
2011-12-07 15:30:01 -05:00
Russ Cox
9b875bc037
bytes: faster Count, Index, Equal
...
Benchmarks are from GOARCH=amd64 on a MacPro5,1.
benchmark old MB/s new MB/s speedup
bytes_test.BenchmarkEqual32 452.89 891.07 1.97x
bytes_test.BenchmarkEqual4K 852.71 1700.44 1.99x
bytes_test.BenchmarkEqual4M 841.53 1587.93 1.89x
bytes_test.BenchmarkEqual64M 838.22 1578.14 1.88x
bytes_test.BenchmarkIndex32 58.02 48.99 0.84x
bytes_test.BenchmarkIndex4K 48.26 41.32 0.86x
bytes_test.BenchmarkIndex4M 48.20 41.24 0.86x
bytes_test.BenchmarkIndex64M 48.08 41.21 0.86x
bytes_test.BenchmarkIndexEasy32 410.04 546.82 1.33x
bytes_test.BenchmarkIndexEasy4K 849.26 14257.37 16.79x
bytes_test.BenchmarkIndexEasy4M 854.54 17222.15 20.15x
bytes_test.BenchmarkIndexEasy64M 843.57 11060.40 13.11x
bytes_test.BenchmarkCount32 57.24 50.68 0.89x
bytes_test.BenchmarkCount4K 48.19 41.82 0.87x
bytes_test.BenchmarkCount4M 48.18 41.74 0.87x
bytes_test.BenchmarkCount64M 48.17 41.71 0.87x
bytes_test.BenchmarkCountEasy32 433.11 547.44 1.26x
bytes_test.BenchmarkCountEasy4K 1130.59 14194.06 12.55x
bytes_test.BenchmarkCountEasy4M 1131.23 17231.18 15.23x
bytes_test.BenchmarkCountEasy64M 1111.40 11068.88 9.96x
The non-easy Count/Index benchmarks are a worst case input.
regexp.BenchmarkMatchEasy0_32 237.46 221.47 0.93x
regexp.BenchmarkMatchEasy0_1K 553.53 1019.72 1.84x
regexp.BenchmarkMatchEasy0_32K 693.99 1672.06 2.41x
regexp.BenchmarkMatchEasy0_1M 688.72 1611.68 2.34x
regexp.BenchmarkMatchEasy0_32M 680.70 1565.05 2.30x
regexp.BenchmarkMatchEasy1_32 165.56 243.08 1.47x
regexp.BenchmarkMatchEasy1_1K 336.45 496.32 1.48x
regexp.BenchmarkMatchEasy1_32K 302.80 425.63 1.41x
regexp.BenchmarkMatchEasy1_1M 300.42 414.20 1.38x
regexp.BenchmarkMatchEasy1_32M 299.64 413.47 1.38x
R=golang-dev, r, iant
CC=golang-dev
https://golang.org/cl/5451116
2011-12-07 15:09:56 -05:00
Christopher Wedgwood
7600281bda
bytes: fix test output
...
R=rsc, gri
CC=golang-dev
https://golang.org/cl/5441048
2011-11-28 09:50:51 -08:00
Russ Cox
558e7fc332
various: avoid func compare
...
R=gri, r, bradfitz
CC=golang-dev
https://golang.org/cl/5371074
2011-11-13 22:57:19 -05:00
Rob Pike
30aa701fec
renaming_2: gofix -r go1pkgrename src/pkg/[a-l]*
...
R=rsc
CC=golang-dev
https://golang.org/cl/5358041
2011-11-08 15:40:58 -08:00
Andrew Gerrand
ed92549071
bytes: fix typo and resolve to be less idiotic next time
...
R=bradfitz
CC=golang-dev
https://golang.org/cl/5340044
2011-11-04 17:55:21 +11:00
Andrew Gerrand
1a4402a1fe
bytes: add Contains function
...
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5349041
2011-11-04 17:46:52 +11:00
Vincent Vanackere
eb1717e035
all: rename os.EOF to io.EOF in various non-code contexts
...
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5334050
2011-11-03 14:01:30 -07:00