summaryrefslogtreecommitdiff
path: root/src/pkg/bytes
AgeCommit message (Collapse)AuthorFilesLines
2011-04-28Imported Upstream version 2011.04.27upstream/2011.04.27Ondřej Surý1-2/+2
2011-04-26Imported Upstream version 2011.04.13upstream/2011.04.13Ondřej Surý3-17/+18
2011-02-18Imported Upstream version 2011.02.15upstream/2011.02.15Ondřej Surý2-16/+31
2011-02-14Imported Upstream version 2011-02-01.1upstream/2011-02-01.1Ondřej Surý2-2/+56
2011-01-17Imported Upstream version 2011.01.12upstream/2011.01.12Ondřej Surý6-376/+770
2010-07-01strings and bytes.Split: make count of 0 mean 0, not infinite.Rob Pike2-34/+46
Use a count of -1 for infinity. Ditto for Replace. R=rsc CC=golang-dev http://codereview.appspot.com/1704044 Committer: Rob Pike <r@golang.org>
2010-06-30bytes, strings: add ReplaceRuss Cox2-0/+69
This is the Replace I suggested in the review of CL 1114041. It's true that we already have regexp.MustCompile(regexp.QuoteMeta(old)).ReplaceAll(s, new) but because this Replace is doing a simpler job it is simpler to call and inherently more efficient. I will add the bytes implementation and tests to the CL after the strings one has been reviewed. R=r, cw CC=golang-dev http://codereview.appspot.com/1731048
2010-06-21big, bytes: move assembly externs to separate fileRuss Cox3-3/+9
to make it easier to build package without assembly. R=r, r2 CC=golang-dev http://codereview.appspot.com/1680045
2010-06-15bytes.Buffer.ReadFrom: fix bug.Rob Pike1-1/+1
Fixes issue 852. R=rsc CC=golang-dev http://codereview.appspot.com/1680042
2010-05-27changes &x -> x[0:] for array to slice conversionRuss Cox1-2/+2
R=gri CC=golang-dev http://codereview.appspot.com/1326042
2010-05-18bytes: add Trim, TrimLeft, TrimRight, and generic functionsMichael Hoisie2-20/+134
R=rsc, r CC=golang-dev http://codereview.appspot.com/946045 Committer: Russ Cox <rsc@golang.org>
2010-05-03bytes: Change IndexAny to look for UTF-8 encoded characters.Rob Pike2-16/+41
Also improve the implementations of Equals and Compare. R=rsc CC=golang-dev http://codereview.appspot.com/969047
2010-04-26bytes: add Next method to Buffer, simplify Read.Russ Cox2-6/+47
R=r CC=golang-dev http://codereview.appspot.com/980043
2010-04-14bytes: shuffle implementation, making WriteByte 50% fasterRuss Cox1-37/+27
R=r CC=golang-dev http://codereview.appspot.com/920041
2010-03-30single argument panicRuss Cox1-1/+2
note that sortmain.go has been run through hg gofmt; only the formatting of the day initializers changed. i'm happy to revert that formatting if you'd prefer. stop on error in doc/progs/run R=r CC=golang-dev http://codereview.appspot.com/850041
2010-03-26bytes, strings: IndexOfAnyRobert Griesemer2-16/+69
+ first use in go/doc R=r CC=golang-dev http://codereview.appspot.com/781041
2010-03-05bufio: WriteRuneRob Pike1-1/+1
also fix a printing error in the test for bytes.Buffer R=golang-dev CC=golang-dev http://codereview.appspot.com/240042
2010-03-05Add ReadRune and WriteRune to bytes.BufferRob Pike2-6/+77
The comments mention bufio's WriteRune, which should come next. R=rsc CC=golang-dev http://codereview.appspot.com/245041
2010-02-25strings: delete Runes, BytesRuss Cox1-15/+14
gofmt -w -r 'strings.Bytes(a) -> []byte(a)' src/cmd src/pkg test/bench gofmt -w -r 'strings.Runes(a) -> []int(a)' src/cmd src/pkg test/bench delete unused imports R=r CC=golang-dev http://codereview.appspot.com/224062
2010-02-17apply gofmt to src and miscRobert Griesemer1-1/+1
R=rsc CC=golang-dev http://codereview.appspot.com/213041
2010-01-25in C and asm, replace pkg·name with ·nameRuss Cox3-4/+4
(eliminate assumption of package global name space, make code easier to move between packages). R=r CC=golang-dev http://codereview.appspot.com/194072
2010-01-02Remove redundant size check in resize. Let callers worry about that and ↵Yongjian Xu1-5/+2
resize should just do "resize". R=golang-dev, r CC=golang-dev http://codereview.appspot.com/181111 Committer: Rob Pike <r@golang.org>
2009-12-19new comments for bytes.NewBuffer and NewBufferString.Rob Pike1-8/+12
corrects a common misunderstanding about NewBuffer. R=rsc CC=golang-dev http://codereview.appspot.com/179106
2009-12-15bytes, strings: add new function FieldsAndrey Mirtchovski2-0/+68
R=rsc, r, phf CC=golang-dev http://codereview.appspot.com/170046 Committer: Russ Cox <rsc@golang.org>
2009-12-15 1) Change default gofmt default settings forRobert Griesemer4-348/+348
parsing and printing to new syntax. Use -oldparser to parse the old syntax, use -oldprinter to print the old syntax. 2) Change default gofmt formatting settings to use tabs for indentation only and to use spaces for alignment. This will make the code alignment insensitive to an editor's tabwidth. Use -spaces=false to use tabs for alignment. 3) Manually changed src/exp/parser/parser_test.go so that it doesn't try to parse the parser's source files using the old syntax (they have new syntax now). 4) gofmt -w src misc test/bench 1st set of files. R=rsc CC=agl, golang-dev, iant, ken2, r http://codereview.appspot.com/180047
2009-12-14When the buffer is empty, reset b.off to the beginning of the bufferRob Pike1-2/+20
to avoid growing unnecessarily. R=rsc CC=golang-dev http://codereview.appspot.com/176071
2009-12-11bytes, strings: allow -1 in Map to mean "drop this character".Kei Son2-9/+25
xml: drop invalid characters in attribute names when constructing struct field names. R=rsc CC=r http://codereview.appspot.com/157104 Committer: Russ Cox <rsc@golang.org>
2009-12-07Remove copyBytes completely in favor of copy.Christopher Wedgwood1-11/+2
R=r, rsc http://codereview.appspot.com/165068 Committer: Rob Pike <r@golang.org>
2009-12-06Make printing faster by avoiding mallocs and some other advances.Rob Pike1-37/+37
Roughly 33% faster for simple cases, probably more for complex ones. Before: mallocs per Sprintf(""): 4 mallocs per Sprintf("xxx"): 6 mallocs per Sprintf("%x"): 10 mallocs per Sprintf("%x %x"): 12 Now: mallocs per Sprintf(""): 2 mallocs per Sprintf("xxx"): 3 mallocs per Sprintf("%x"): 5 mallocs per Sprintf("%x %x"): 7 Speed improves because of avoiding mallocs and also by sharing a bytes.Buffer between print.go and format.go rather than copying the data back after each printed item. Before: fmt_test.BenchmarkSprintfEmpty 1000000 1346 ns/op fmt_test.BenchmarkSprintfString 500000 3461 ns/op fmt_test.BenchmarkSprintfInt 500000 3671 ns/op Now: fmt_test.BenchmarkSprintfEmpty 2000000 995 ns/op fmt_test.BenchmarkSprintfString 1000000 2745 ns/op fmt_test.BenchmarkSprintfInt 1000000 2391 ns/op fmt_test.BenchmarkSprintfIntInt 500000 3751 ns/op I believe there is more to get but this is a good milestone. R=rsc CC=golang-dev, hong http://codereview.appspot.com/166076
2009-12-04bytes: asm for bytes.IndexByteRuss Cox7-1/+96
PERFORMANCE DIFFERENCE SUMMARY amd64 386 2.2 GHz AMD Opteron 8214 HE (Linux) 3.0x faster 8.2x faster 3.60 GHz Intel Xeon (Linux) 2.2x faster 6.2x faster 2.53 GHz Intel Core2 Duo E7200 (Linux) 1.5x faster 4.4x faster 2.66 Ghz Intel Xeon 5150 (Mac Pro, OS X) 1.5x SLOWER 3.0x faster 2.33 GHz Intel Xeon E5435 (Linux) 1.5x SLOWER 3.0x faster 2.33 GHz Intel Core2 T7600 (MacBook Pro, OS X) 1.4x SLOWER 3.0x faster 1.83 GHz Intel Core2 T5600 (Mac Mini, OS X) none* 3.0x faster * but yesterday I consistently saw 1.4x SLOWER. DETAILS 2.2 GHz AMD Opteron 8214 HE (Linux) amd64 (3x faster) IndexByte4K 500000 3733 ns/op 1097.24 MB/s IndexByte4M 500 4328042 ns/op 969.10 MB/s IndexByte64M 50 67866160 ns/op 988.84 MB/s IndexBytePortable4K 200000 11161 ns/op 366.99 MB/s IndexBytePortable4M 100 11795880 ns/op 355.57 MB/s IndexBytePortable64M 10 188675000 ns/op 355.68 MB/s 386 (8.2x faster) IndexByte4K 500000 3734 ns/op 1096.95 MB/s IndexByte4M 500 4209954 ns/op 996.28 MB/s IndexByte64M 50 68031980 ns/op 986.43 MB/s IndexBytePortable4K 50000 30670 ns/op 133.55 MB/s IndexBytePortable4M 50 31868220 ns/op 131.61 MB/s IndexBytePortable64M 2 508851500 ns/op 131.88 MB/s 3.60 GHz Intel Xeon (Linux) amd64 (2.2x faster) IndexByte4K 500000 4612 ns/op 888.12 MB/s IndexByte4M 500 4835250 ns/op 867.44 MB/s IndexByte64M 20 77388450 ns/op 867.17 MB/s IndexBytePortable4K 200000 10306 ns/op 397.44 MB/s IndexBytePortable4M 100 11201460 ns/op 374.44 MB/s IndexBytePortable64M 10 179456800 ns/op 373.96 MB/s 386 (6.3x faster) IndexByte4K 500000 4631 ns/op 884.47 MB/s IndexByte4M 500 4846388 ns/op 865.45 MB/s IndexByte64M 20 78691200 ns/op 852.81 MB/s IndexBytePortable4K 100000 28989 ns/op 141.29 MB/s IndexBytePortable4M 50 31183180 ns/op 134.51 MB/s IndexBytePortable64M 5 498347200 ns/op 134.66 MB/s 2.53 GHz Intel Core2 Duo E7200 (Linux) amd64 (1.5x faster) IndexByte4K 500000 6502 ns/op 629.96 MB/s IndexByte4M 500 6692208 ns/op 626.74 MB/s IndexByte64M 10 107410400 ns/op 624.79 MB/s IndexBytePortable4K 200000 9721 ns/op 421.36 MB/s IndexBytePortable4M 100 10013680 ns/op 418.86 MB/s IndexBytePortable64M 10 160460800 ns/op 418.23 MB/s 386 (4.4x faster) IndexByte4K 500000 6505 ns/op 629.67 MB/s IndexByte4M 500 6694078 ns/op 626.57 MB/s IndexByte64M 10 107397600 ns/op 624.86 MB/s IndexBytePortable4K 100000 28835 ns/op 142.05 MB/s IndexBytePortable4M 50 29562680 ns/op 141.88 MB/s IndexBytePortable64M 5 473221400 ns/op 141.81 MB/s 2.66 Ghz Intel Xeon 5150 (Mac Pro, OS X) amd64 (1.5x SLOWER) IndexByte4K 200000 9290 ns/op 440.90 MB/s IndexByte4M 200 9568925 ns/op 438.33 MB/s IndexByte64M 10 154473600 ns/op 434.44 MB/s IndexBytePortable4K 500000 6202 ns/op 660.43 MB/s IndexBytePortable4M 500 6583614 ns/op 637.08 MB/s IndexBytePortable64M 20 107166250 ns/op 626.21 MB/s 386 (3x faster) IndexByte4K 200000 9301 ns/op 440.38 MB/s IndexByte4M 200 9568025 ns/op 438.37 MB/s IndexByte64M 10 154391000 ns/op 434.67 MB/s IndexBytePortable4K 100000 27526 ns/op 148.80 MB/s IndexBytePortable4M 100 28302490 ns/op 148.20 MB/s IndexBytePortable64M 5 454170200 ns/op 147.76 MB/s 2.33 GHz Intel Xeon E5435 (Linux) amd64 (1.5x SLOWER) IndexByte4K 200000 10601 ns/op 386.38 MB/s IndexByte4M 100 10827240 ns/op 387.38 MB/s IndexByte64M 10 173175500 ns/op 387.52 MB/s IndexBytePortable4K 500000 7082 ns/op 578.37 MB/s IndexBytePortable4M 500 7391792 ns/op 567.43 MB/s IndexBytePortable64M 20 122618550 ns/op 547.30 MB/s 386 (3x faster) IndexByte4K 200000 11074 ns/op 369.88 MB/s IndexByte4M 100 10902620 ns/op 384.71 MB/s IndexByte64M 10 181292800 ns/op 370.17 MB/s IndexBytePortable4K 50000 31725 ns/op 129.11 MB/s IndexBytePortable4M 50 32564880 ns/op 128.80 MB/s IndexBytePortable64M 2 545926000 ns/op 122.93 MB/s 2.33 GHz Intel Core2 T7600 (MacBook Pro, OS X) amd64 (1.4x SLOWER) IndexByte4K 200000 11120 ns/op 368.35 MB/s IndexByte4M 100 11531950 ns/op 363.71 MB/s IndexByte64M 10 184819000 ns/op 363.11 MB/s IndexBytePortable4K 500000 7419 ns/op 552.10 MB/s IndexBytePortable4M 200 8018710 ns/op 523.06 MB/s IndexBytePortable64M 10 127614900 ns/op 525.87 MB/s 386 (3x faster) IndexByte4K 200000 11114 ns/op 368.54 MB/s IndexByte4M 100 11443530 ns/op 366.52 MB/s IndexByte64M 10 185212000 ns/op 362.34 MB/s IndexBytePortable4K 50000 32891 ns/op 124.53 MB/s IndexBytePortable4M 50 33930580 ns/op 123.61 MB/s IndexBytePortable64M 2 545400500 ns/op 123.05 MB/s 1.83 GHz Intel Core2 T5600 (Mac Mini, OS X) amd64 (no difference) IndexByte4K 200000 13497 ns/op 303.47 MB/s IndexByte4M 100 13890650 ns/op 301.95 MB/s IndexByte64M 5 222358000 ns/op 301.81 MB/s IndexBytePortable4K 200000 13584 ns/op 301.53 MB/s IndexBytePortable4M 100 13913280 ns/op 301.46 MB/s IndexBytePortable64M 10 222572600 ns/op 301.51 MB/s 386 (3x faster) IndexByte4K 200000 13565 ns/op 301.95 MB/s IndexByte4M 100 13882640 ns/op 302.13 MB/s IndexByte64M 5 221411600 ns/op 303.10 MB/s IndexBytePortable4K 50000 39978 ns/op 102.46 MB/s IndexBytePortable4M 50 41038160 ns/op 102.20 MB/s IndexBytePortable64M 2 656362500 ns/op 102.24 MB/s R=r CC=golang-dev http://codereview.appspot.com/166055
2009-12-04avoid an allocation inside bytes.Buffer by providing a static array.Rob Pike1-8/+4
R=rsc http://codereview.appspot.com/165058
2009-12-03Add ReadFrom and WriteTo methods to bytes.Buffer, to enable i/o without ↵Rob Pike2-0/+77
buffer allocation. Use them in Copy and Copyn. Speed up ReadFile by using ReadFrom and avoiding Copy altogether (a minor win). R=rsc, gri CC=golang-dev http://codereview.appspot.com/166041
2009-12-02Runes: turn string into []intPeter Froehlich2-0/+59
Split: fixed typo in documentation R=rsc, r, r1 http://codereview.appspot.com/157170 Committer: Russ Cox <rsc@golang.org>
2009-11-23go: makes it build for the case $GOROOT has whitespacesSergio Luis O. B. Correia1-2/+2
the bash scripts and makefiles for building go didn't take into account the fact $GOROOT / $GOBIN could both be directories containing whitespaces, and was not possible to build it in such a situation. this commit adjusts the various makefiles/scripts to make it aware of that possibility, and now it builds successfully when using a path with whitespaces as well. Fixes issue 115. R=rsc, dsymonds1 http://codereview.appspot.com/157067 Committer: Russ Cox <rsc@golang.org>
2009-11-20gofmt -r 'α[β:len(α)] -> α[β:]' -w src/cmd src/pkgRuss Cox3-9/+9
R=r, gri CC=golang-dev http://codereview.appspot.com/156115
2009-11-18add bytes.IndexByte; common case we can make fast later.Rob Pike2-17/+69
also pick off the special case in strings.Index. don't want strings.IndexByte because the call site will very rarely need to allocate and we can handle the test in the code itself. bytes.IndexByte can avoid a common allocation. R=rsc CC=golang-dev http://codereview.appspot.com/156091
2009-11-18remove bytes.CopyRob Pike3-50/+7
replace all calls with calls to copy use copy in regexp and bytes.Buffer R=rsc CC=golang-dev http://codereview.appspot.com/157073
2009-11-16 An asked-for-in #go-nuts extension to quickly create a repeatedDavid G. Andersen2-0/+40
copy of a string or a byte array. strings.Repeat("-", 50) bytes.Repeat(b, 99) R=rsc http://codereview.appspot.com/155063 Committer: Russ Cox <rsc@golang.org>
2009-11-15fix bug in bytes.Map and add test cases for Map in both strings and bytes ↵Rob Pike2-3/+29
packages. thanks to ulrik.sverdrup for the test case. Fixes issue 191. R=rsc CC=golang-dev http://codereview.appspot.com/155056
2009-11-10minor adjustments to package comments for better synopsis.Robert Griesemer1-1/+1
R=rsc CC=r http://go/go-review/1026038
2009-11-09- replaced gofmt expression formatting algorithm withRobert Griesemer4-41/+41
rsc's algorithm - applied gofmt -w misc src - partial CL (remaining files in other CLs) R=rsc, r http://go/go-review/1024040
2009-11-09remove semis after statements in one-statement statement listsRobert Griesemer4-78/+78
R=rsc, r http://go/go-review/1025029
2009-11-06- fine-tuning of one-line func heuristic (nodes.go)Robert Griesemer3-33/+11
- enabled for function declarations (not just function literals) - applied gofmt -w $GOROOT/src (look for instance at src/pkg/debug/elf/elf.go) R=r, rsc CC=go-dev http://go/go-review/1026006
2009-11-04gofmt-ify bytesRobert Griesemer2-3/+4
R=r http://go/go-review/1016044
2009-11-04bytes.SplitAfter and strings.SplitAfterRuss Cox2-5/+50
most common usage is: lines := strings.SplitAfter(text, "\n", 0) R=r http://go/go-review/1018042
2009-10-31return "<nil>" when calling String() on a nil bytes.Buffer.Rob Pike2-1/+13
R=rsc CC=go-dev http://go/go-review/1016005
2009-10-27files that are okay from the last gofmt roundRuss Cox2-13/+9
R=gri http://go/go-review/1015011
2009-10-21fix typo/oversight: s/Title/ToTitle/. the comment was already correctRob Pike1-1/+1
R=rsc DELTA=1 (0 added, 0 deleted, 1 changed) OCL=35964 CL=35979
2009-10-12fix comment on strings.LastIndex.Russ Cox1-0/+15
add bytes.LastIndex. add strings.Reader. R=r DELTA=59 (56 added, 0 deleted, 3 changed) OCL=35585 CL=35601
2009-10-08more lgtm files from gofmtRuss Cox3-93/+103
R=gri OCL=35485 CL=35488