1
0
mirror of https://github.com/golang/go synced 2024-10-04 16:21:22 -06:00
Commit Graph

79 Commits

Author SHA1 Message Date
Rob Pike
45e3bcb343 renaming_3: gofix -r go1pkgrename src/pkg/[m-z]*
R=rsc
CC=golang-dev
https://golang.org/cl/5345045
2011-11-08 15:41:54 -08: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
Russ Cox
eb6929299b src/pkg/[n-z]*: gofix -r error -force=error
R=golang-dev, bsiegert, iant
CC=golang-dev
https://golang.org/cl/5294074
2011-11-01 22:05:34 -04:00
Russ Cox
8f5718176f bytes, strings: use rune
Various rune-based APIs change.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5306044
2011-10-25 22:22:09 -07:00
Brad Fitzpatrick
bba7396fbd strings: implement a faster byte->string Replacer
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
2011-10-03 15:19:04 -07:00
Brad Fitzpatrick
f75ff01f44 strings: implement a faster byte->byte Replacer
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
2011-10-03 13:12:01 -07:00
Brad Fitzpatrick
7b0f3caa26 strings: add Replacer, NewReplacer
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
2011-09-28 09:34:26 -07:00
Russ Cox
c68ae9d467 bytes: add EqualFold
R=golang-dev, r, r
CC=golang-dev
https://golang.org/cl/5123047
2011-09-26 19:35:32 -04:00
Russ Cox
a8a18f6566 strings: add EqualFold
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
2011-09-26 18:32:51 -04:00
Robert Griesemer
90564a9256 go/printer: changed max. number of newlines from 3 to 2
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
2011-07-14 14:39:40 -07:00
Rob Pike
ebb1566a46 strings.Split: make the default to split all.
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
2011-06-28 09:43:14 +10:00
Robert Griesemer
712fb6dcd3 os.Error API: don't export os.ErrorString, use os.NewError consistently
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
2011-06-22 10:52:47 -07:00
Brad Fitzpatrick
219805066e http: have client set Content-Length when possible
Also some cleanup, removing redundant code. Make more
things use NewRequest. Add some tests, docs.

R=golang-dev, adg, rsc
CC=golang-dev
https://golang.org/cl/4561047
2011-05-31 08:47:03 -07:00
Robert Griesemer
9cd3372f9b strings: implement UnreadByte, UnreadRune
Added corresponding tests.

R=rsc
CC=golang-dev
https://golang.org/cl/4560045
2011-05-26 11:02:07 -07:00
Nigel Tao
77d66f4131 strings: make Reader.Read use copy instead of an explicit loop.
R=r, bradfitz, r
CC=golang-dev
https://golang.org/cl/4529064
2011-05-15 13:14:10 -07:00
Nigel Tao
6a186d38d1 src/pkg: make package doc comments consistently start with "Package foo".
R=rsc
CC=golang-dev
https://golang.org/cl/4442064
2011-04-20 09:57:05 +10:00
Evan Shaw
47f4ae1a78 bytes, strings: simplify Join
R=gri, rsc
CC=golang-dev
https://golang.org/cl/4300044
2011-03-29 01:27:38 -04:00
Brad Fitzpatrick
a7a854b82f strings: Map: avoid allocation when string is unchanged
This speeds up strings.ToLower, etc.

before/after:
strings_test.BenchmarkMapNoChanges 1000000 1013 ns/op
strings_test.BenchmarkMapNoChanges 5000000  442 ns/op

R=r, rog, eh, rsc
CC=golang-dev
https://golang.org/cl/4306056
2011-03-28 09:41:57 -07:00
Rob Pike
f0cf7d296c testing: shorten some tests.
These are the top runners.  More to come.
Also print two digits of timing info under -test.v.

R=rsc
CC=golang-dev
https://golang.org/cl/4317044
2011-03-25 16:31:10 -07:00
Brad Fitzpatrick
64f75f1034 strings: better benchmark names; add BenchmarkIndex
R=dsymonds
CC=golang-dev
https://golang.org/cl/4264052
2011-03-08 09:58:18 -08:00
Brad Fitzpatrick
145108ed36 strings: add IndexRune tests, ASCII fast path
$ gotest -test.v -test.run=IndexRune -test.bench=.*
=== RUN  strings_test.TestIndexRune
--- PASS: strings_test.TestIndexRune (0.0 seconds)
PASS
strings_test.BenchmarkIndexRune	20000000   105 ns/op
strings_test.BenchmarkIndexByte	50000000    48 ns/op

R=rsc, dsymonds
CC=golang-dev
https://golang.org/cl/4267050
2011-03-08 09:41:12 -08:00
Roger Peppe
2f5a5be237 strings: fix description of FieldsFunc
R=r
CC=golang-dev
https://golang.org/cl/3814041
2011-01-04 16:23:29 -08:00
Adam Langley
3cb4bdb9ce utf8: make EncodeRune's destination the first argument.
R=r
CC=golang-dev
https://golang.org/cl/3364041
2010-11-30 16:59:43 -05:00
Benny Siegert
8530e8ef65 strings: add LastIndexAny
The need for a LastIndexAny function has come up in the discussion
for https://golang.org/cl/3008041/. This function is
implemented analogously to lastIndexFunc, using functions from
the utf8 package.

R=r, rsc, PeterGo
CC=golang-dev
https://golang.org/cl/3057041
2010-11-12 12:47:50 -08:00
Brad Fitzpatrick
e198a5086a strings: Contains
Tiny helper to avoid strings.Index(s, sub) != -1

R=rsc, r2, r
CC=golang-dev
https://golang.org/cl/2265044
2010-11-01 14:32:48 -07:00
Russ Cox
d86ab015f7 use copy
R=gri
CC=golang-dev
https://golang.org/cl/2763041
2010-10-26 21:52:54 -07:00
Robert Griesemer
3478891d12 gofmt -s -w src misc
R=r, rsc
CC=golang-dev
https://golang.org/cl/2662041
2010-10-22 10:06:33 -07:00
Roger Peppe
81ba399a6a bytes, strings: change lastIndexFunc to use DecodeLastRune
R=r
CC=golang-dev, rsc
https://golang.org/cl/2271041
2010-09-23 20:40:11 +10:00
Roger Peppe
8ee986570a strings: fix minor bug in LastIndexFunc
R=r, rsc
CC=golang-dev
https://golang.org/cl/2250042
2010-09-21 22:58:09 -04:00
Russ Cox
da392d9136 build: no required environment variables
R=adg, r, PeterGo
CC=golang-dev
https://golang.org/cl/1942044
2010-08-18 10:08:49 -04:00
Christian Himpel
75f6a0c759 bytes: add IndexRune, FieldsFunc and To*Special
Basically these functions are implemented the same way as the
corresponding functions in the strings package.  Test functions
are implemented for IndexRune and FieldsFunc.

Additionally two typos are fixed in packages bytes and strings.

R=r
CC=golang-dev
https://golang.org/cl/1696062
2010-08-05 23:11:06 +10:00
Scott Lawrence
0cd8777255 strings: fix Split("", "", -1)
Fixes #980.

Made it return an empty array, rather than crash.
Added relevant test cases to strings.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/1914041
2010-08-03 13:35:14 +10:00
Andrew Gerrand
8b821696cc bytes, strings: mention the n < 0 case in Split/SplitAfter doc comment
R=r, rsc
CC=golang-dev
https://golang.org/cl/1669055
2010-07-27 15:06:08 +10:00
Fazlul Shahriar
e356f1d88f bytes: port IndexFunc and LastIndexFunc from strings package
This CL basically applies the same changes as

	http://code.google.com/p/go/source/detail?r=5e0a29014e8e

but for bytes package.

R=r, rog
CC=golang-dev
https://golang.org/cl/1670052
2010-07-23 12:34:35 -07:00
Rob Pike
8684a08989 strings: add Title
strings.ToTitle converts all characters to title case, which for consistency with the
other To* functions it should continue to do.  This CL adds string.Title, which
does a proper title-casing of the string.
A similar function for package bytes will follow once this is settled.
Fixes #933.

R=rsc
CC=golang-dev
https://golang.org/cl/1869042
2010-07-20 00:03:59 -07:00
Rob Pike
38f1231f3e strings and bytes.Split: make count of 0 mean 0, not infinite.
Use a count of -1 for infinity.  Ditto for Replace.

R=rsc
CC=golang-dev
https://golang.org/cl/1704044
2010-07-01 14:08:14 -07:00
Russ Cox
0bf413ab8e bytes, strings: add Replace
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
https://golang.org/cl/1731048
2010-06-30 18:03:09 -07:00
Roger Peppe
18274e0075 Add IndexFunc and LastIndexFunc.
Change TrimRight and TrimLeft to use these functions.
Incidentally fix minor bug in TrimRight.
Add some test cases for this.
YMMV whether it's worth saving the closure allocation.

R=r, r2
CC=golang-dev, hoisie, rsc
https://golang.org/cl/1198044
2010-06-14 14:54:48 -07:00
Kyle Consalus
24bfd652ee Conversion from loop to copy().
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/1072041
2010-05-05 09:57:53 -07:00
Kyle Consalus
d7b4851586 strings: add ReadRune to Reader
R=rsc
CC=golang-dev
https://golang.org/cl/940041
2010-04-20 22:18:26 -07:00
Kyle Consalus
ad2c5a4984 Added strings.FieldsFunc, a generalization of strings.Fields in style of the strings.Trim*Func functions.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/824051
2010-04-19 16:36:50 -07:00
Michael Hoisie
92ac0cfbb2 strings: add IndexRune, Trim, TrimLeft, TrimRight, and the generic equivalents TrimFunc, TrimLeftFunc, TrimRightFunc
R=rsc, r
CC=golang-dev
https://golang.org/cl/799048
2010-04-09 18:57:03 -07:00
Rob Pike
4e2b7f8f41 Unicode: provide an ability to supplement the case-mapping tables
in character and string case mapping routines.

Add a custom mapper for Turkish and Azeri.

A more general solution for deriving the case information from Unicode's
SpecialCasing.txt will require more work.

Fixes #703.

R=rsc, rsc1
CC=golang-dev, mdakin
https://golang.org/cl/824043
2010-03-30 17:51:03 -07:00
Rob Pike
299cd38f0a strings.FIelds: slight simplification.
R=rsc
CC=golang-dev
https://golang.org/cl/833042
2010-03-29 13:39:16 -07:00
Robert Griesemer
d0ffee8abf bytes, strings: IndexOfAny
+ first use in go/doc

R=r
CC=golang-dev
https://golang.org/cl/781041
2010-03-26 13:05:04 -07:00
Spring Mc
3dcbf73c84 strings: make Split(s, "", n) faster
R=rsc
CC=golang-dev
https://golang.org/cl/223096
2010-03-04 16:15:51 -08:00
Russ Cox
9750adbbad strings: delete Runes, Bytes
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
https://golang.org/cl/224062
2010-02-25 16:01:29 -08:00
Robert Griesemer
859e4d51c3 strings: remove a couple of redundant tests
(per suggestion from Heresy.Mc@gmail.com)

R=rsc
CC=golang-dev
https://golang.org/cl/223052
2010-02-25 10:02:39 -08:00
Andrey Mirtchovski
7f501c06f7 bytes, strings: add new function Fields
R=rsc, r, phf
CC=golang-dev
https://golang.org/cl/170046
2009-12-15 21:09:55 -08:00
Robert Griesemer
d65a5cce89 1) Change default gofmt default settings for
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

4th set of files.

R=rsc
CC=golang-dev
https://golang.org/cl/180049
2009-12-15 15:40:16 -08:00