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

78 Commits

Author SHA1 Message Date
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
Nigel Tao
833529fd6f compress/lzw: reduce decoder buffer size from 3*4096 to 2*4096.
This happens to speed up the decoder benchmarks by 50% on my computer
(GOARCH=amd64 GOOS=linux), but I don't have a good intuition as to why.
For example, just adding an unused [4096]byte field to the decoder
struct doesn't significantly change the numbers.

Before:

lzw.BenchmarkDecoder1e4	    5000	    488057 ns/op	  20.49 MB/s
lzw.BenchmarkDecoder1e5	     500	   4613638 ns/op	  21.67 MB/s
lzw.BenchmarkDecoder1e6	      50	  45672260 ns/op	  21.90 MB/s
lzw.BenchmarkEncoder1e4	    5000	    353563 ns/op	  28.28 MB/s
lzw.BenchmarkEncoder1e5	     500	   3431618 ns/op	  29.14 MB/s
lzw.BenchmarkEncoder1e6	      50	  34009640 ns/op	  29.40 MB/s

After:

lzw.BenchmarkDecoder1e4	    5000	    339725 ns/op	  29.44 MB/s
lzw.BenchmarkDecoder1e5	     500	   3166894 ns/op	  31.58 MB/s
lzw.BenchmarkDecoder1e6	      50	  31317260 ns/op	  31.93 MB/s
lzw.BenchmarkEncoder1e4	    5000	    354909 ns/op	  28.18 MB/s
lzw.BenchmarkEncoder1e5	     500	   3432710 ns/op	  29.13 MB/s
lzw.BenchmarkEncoder1e6	      50	  34010500 ns/op	  29.40 MB/s

R=rsc, r
CC=golang-dev
https://golang.org/cl/4535123
2011-06-09 09:50:38 +10:00
Russ Cox
63dae3c3be compress/lzw: do not use background goroutines
Programs expect that Read and Write are synchronous.
The background goroutines make the implementation
a little easier, but they introduce asynchrony that
trips up calling code.  Remove them.

R=golang-dev, nigeltao
CC=golang-dev
https://golang.org/cl/4548080
2011-06-07 14:37:06 -04:00
Russ Cox
07acc02a29 compress/flate: do not use background goroutines
Programs expect that Read and Write are synchronous.
The background goroutines make the implementation
a little easier, but they introduce asynchrony that
trips up calling code.  Remove them.

R=golang-dev, krasin
CC=golang-dev
https://golang.org/cl/4548079
2011-06-02 09:32:38 -04:00
Ivan Krasin
1b5d04c5ae compress/flate: fix Huffman tree bug
Incorporate refactoring and a regression test from https://golang.org/cl/4538090/

R=rsc, go.peter.90, imkrasin
CC=golang-dev, mirtchovski
https://golang.org/cl/4524070
2011-05-26 17:02:11 -04:00
Robert Hencke
c8727c81bb pkg: spelling tweaks, A-H
R=ality, bradfitz, rsc, dsymonds, adg, qyzhai, dchest
CC=golang-dev
https://golang.org/cl/4536063
2011-05-18 13:14:56 -04:00
Adam Langley
d080a1cf14 compress/zlib: actually use provided dictionary.
R=rsc, bradfitz, bradfitzgoog
CC=golang-dev
https://golang.org/cl/4518056
2011-05-11 17:00:19 -04:00
Nigel Tao
f467803dcd compress/lzw: silently drop implied codes that are too large,
instead of returning an error.

For example, http://www.w3.org/Graphics/GIF/spec-gif89a.txt
explicitly says that GIF encoders can use a full table as is,
without needing to send a clear code.

R=r, dsymonds, nigeltao_gnome, r2
CC=golang-dev
https://golang.org/cl/4518041
2011-05-07 18:57:32 -07:00
Brad Fitzpatrick
437015bbed png: speed up opaque RGBA encoding
With Linux/8g on a 2006 Mac Mini (1.66 GHz Intel Core Duo,
2KB L1, 2MB L2, 2G main memory), GOMAXPROCS unset:

start:
png.BenchmarkEncodePaletted	      50	  44772820 ns/op
png.BenchmarkEncodeRGBOpaque	      10	 208395900 ns/op
png.BenchmarkEncodeRGBA		       5	 331088000 ns/op

remove interface method calls:
png.BenchmarkEncodePaletted	      50	  44722880 ns/op
png.BenchmarkEncodeRGBOpaque	      10	 139042600 ns/op
png.BenchmarkEncodeRGBA		       5	 334033600 ns/op

flate inline min/max():
png.BenchmarkEncodePaletted	      50	  40631180 ns/op
png.BenchmarkEncodeRGBOpaque	      10	 124894900 ns/op
png.BenchmarkEncodeRGBA		       5	 312099000 ns/op

after adler change:
png.BenchmarkEncodePaletted	      50	  40181760 ns/op
png.BenchmarkEncodeRGBOpaque	      20	 121781950 ns/op
png.BenchmarkEncodeRGBA		       5	 313890800 ns/op

In comparison to 121 ms on this 2006 machine, on my
Core2 Duo 2.66 GHz laptop, the final BenchmarkEncodeRGBOpaque
runs in 27 ms. (these are all for 640x480 images)

R=nigeltao, rsc, r
CC=golang-dev
https://golang.org/cl/4432077
2011-05-02 07:25:53 -07:00
Brad Fitzpatrick
9d12307a12 ioutil: add Discard, update tree.
This also removes an unnecessary allocation in
http/transfer.go

R=r, rsc1, r2, adg
CC=golang-dev
https://golang.org/cl/4426066
2011-04-27 15:47:04 -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
Ross Light
bfb486875a compress/zlib: add FDICT flag in Reader/Writer
R=bradfitzgo, rsc, bradfitzwork
CC=golang-dev
https://golang.org/cl/4406046
2011-04-15 15:32:03 -07:00
Russ Cox
36713a2a53 compress/flate: dictionary support
R=bradfitzwork
CC=golang-dev
https://golang.org/cl/4397043
2011-04-14 10:41:55 -04:00
Rob Pike
8a90fd3c72 os: New Open API.
We replace the current Open with:
OpenFile(name, flag, perm) // same as old Open
Open(name) // same as old Open(name, O_RDONLY, 0)
Create(name) // same as old Open(name, O_RDWR|O_TRUNC|O_CREAT, 0666)

This CL includes a gofix module and full code updates: all.bash passes.
(There may be a few comments I missed.)

The interesting packages are:
        gofix
        os
Everything else is automatically generated except for hand tweaks to:
        src/pkg/io/ioutil/ioutil.go
        src/pkg/io/ioutil/tempfile.go
        src/pkg/crypto/tls/generate_cert.go
        src/cmd/goyacc/goyacc.go
        src/cmd/goyacc/units.y

R=golang-dev, bradfitzwork, rsc, r2
CC=golang-dev
https://golang.org/cl/4357052
2011-04-04 23:42:14 -07:00
Nigel Tao
78879b3b8b compress/lzw: benchmark a range of input sizes.
R=rsc, nigeltao_gnome
CC=golang-dev
https://golang.org/cl/4240096
2011-03-09 16:32:02 +11:00
Russ Cox
d044674a0d compress/flate: fix test
The test was checking for a buffer to be empty but
actually racing with the background goroutine that
was emptying it.  Left a comment so that the check
is not reintroduced later.

Fixes #1557.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4248063
2011-03-05 14:35:03 -05:00
Adam Langley
e7fa307902 bzip2: speed up decompression.
This borrows a trick from the bzip2 source and effects a decent speed
up when decompressing highly compressed sources. Rather than unshuffle
the BTW block when performing the IBTW, a linked-list is threaded
through the array, in place. This improves cache hit rates.

R=bradfitzgo, bradfitzwork, cw
CC=golang-dev
https://golang.org/cl/4247047
2011-03-03 09:13:06 -05:00
Nigel Tao
fdbbb066ed compress/lzw: don't use a closure in NewReader, which avoids having
to move some variables from the stack to the heap.

Sorted benchmark runs on my 2007-era Mac Mini (GOARCH=amd64, GOOS=linux):

Before:
lzw.BenchmarkDecoder        2000        878176 ns/op
lzw.BenchmarkDecoder        2000        878415 ns/op
lzw.BenchmarkDecoder        2000        880352 ns/op
lzw.BenchmarkDecoder        2000        898445 ns/op
lzw.BenchmarkDecoder        2000        901728 ns/op

After:
lzw.BenchmarkDecoder        2000        859065 ns/op
lzw.BenchmarkDecoder        2000        859402 ns/op
lzw.BenchmarkDecoder        2000        860035 ns/op
lzw.BenchmarkDecoder        2000        860555 ns/op
lzw.BenchmarkDecoder        2000        861109 ns/op

The ratio of before/after median times is 1.024.

The runtime.MemStats.Mallocs delta per loop drops from 109 to 104.

R=r, r2, dfc
CC=golang-dev
https://golang.org/cl/4253043
2011-02-26 16:42:49 +11:00
Nigel Tao
5b1d47d105 compress/lzw: fix the stupidity of allocating and zeroing a new buffer
on each loop iteration, yielding a 20x performance improvement.

R=rsc, r2
CC=golang-dev
https://golang.org/cl/4240044
2011-02-26 09:25:29 +11:00
Nigel Tao
741eab4eb6 compress/lzw: implement an encoder.
R=rsc, nigeltao_gnome
CC=golang-dev
https://golang.org/cl/4209043
2011-02-25 09:20:04 +11:00
Adam Langley
da8e6eec9a compress/bzip2: fix bugs
(Once again, proving that a fuzz tester is the first thing that I
should try.)

R=bradfitzgo
CC=golang-dev
https://golang.org/cl/4227042
2011-02-23 12:02:41 -05:00
Adam Langley
bf6939829d compress/bzip2: add package.
This code implements bzip2 decompression only.

R=bradfitzgo, r2, nigeltao, rsc
CC=golang-dev
https://golang.org/cl/4176051
2011-02-23 10:23:28 -05:00
Nigel Tao
658447ab66 compress/lzw: implement a decoder.
R=rsc
CC=bsiegert, golang-dev, mpl
https://golang.org/cl/4182081
2011-02-23 20:52:43 +11:00
Nigel Tao
1c5ed263ae compress: move zlib/testdata to testdata so it can be shared by all
compression algorithms.

R=rsc, r2, nigeltao_gnome
CC=golang-dev
https://golang.org/cl/4188054
2011-02-16 11:41:29 +11:00
Russ Cox
f4e76d8309 replace non-blocking send, receive syntax with select
R=golang-dev, nigeltao, niemeyer, r
CC=golang-dev
https://golang.org/cl/4079053
2011-01-31 18:36:28 -05:00
Russ Cox
f620a430f2 compress/flate: implement Flush
This Flush is equivalent to zlib's Z_SYNC_FLUSH.
The addition of the explicit Writer type opens the
door to adding a PartialFlush if needed for SSH
and maybe even FullFlush.  It also opens the door
for a SetDictionary method to be added.

http://www.bolet.org/~pornin/deflate-flush.html
documents the various intricacies of flushing a
DEFLATE stream.

R=agl1, r
CC=golang-dev
https://golang.org/cl/3637041
2010-12-14 14:57:12 -05:00
Mathieu Lonjaret
387d58e790 compress/flate: fix typo in comment.
R=golang-dev, nigeltao_gnome, nigeltao
CC=golang-dev
https://golang.org/cl/3334041
2010-11-26 13:05:22 +11: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
Russ Cox
be443ee8bc 5g: register allocation bugs
Fixes #1099.

R=ken2, r
CC=golang-dev
https://golang.org/cl/2147047
2010-09-12 00:06:45 -04:00
Rob Pike
0aa2317096 arm: work around reg allocator bug in 5g, in two parts.
1) hack regalloc to leave R9 (m) and R10 (g) alone.
the real fix is tricker, but this gets us running
2) fix up the few places in the package sources that
the shortage of registers affects, by simplifying
some expressions.

all of this should be reverted when the right fix is in.

Fixes #1084.

R=rsc
CC=golang-dev
https://golang.org/cl/2132046
2010-09-10 20:55:29 -07: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
Robert Griesemer
8f9aeb5a66 gofmt: fix some linebreak issues
- don't lose empty lines after labels
- canonicalize number of line breaks
- gofmt src misc, fixes a couple of irregular breaks

R=rsc
CC=golang-dev
https://golang.org/cl/1843044
2010-07-20 09:29:31 -07:00
Russ Cox
bb84f4b5d2 changes &x -> x[0:] for array to slice conversion
R=gri
CC=golang-dev
https://golang.org/cl/1326042
2010-05-27 14:51:47 -07:00
Rob Pike
f023e859cf compress: renamings.
NewDeflater -> NewWriter
NewInflater -> NewReader
Deflater -> Compressor
Inflater -> Decompressor

R=rsc
CC=golang-dev
https://golang.org/cl/1166041
2010-05-07 14:32:34 -07:00
Robert Griesemer
f44fa9b4c7 gofmt: experiment: align values in map composites where possible
- gofmt -w src misc
- looking for feedback

R=rsc, r
CC=golang-dev
https://golang.org/cl/223076
2010-03-02 13:46:51 -08:00
Andrey Mirtchovski
1f3222a57b strings.Bytes -> []byte for documentation example, src/pkg/* comments, and htmlgen.go
R=rsc, adg
CC=golang-dev
https://golang.org/cl/224087
2010-03-02 11:18:22 +11: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
Nigel Tao
5647e604f7 Check gzip strings for NUL elements, since they are NUL-terminated
on the wire.

R=rsc
CC=golang-dev
https://golang.org/cl/194146
2010-01-30 12:21:51 +11:00
Nigel Tao
af7e0f1bdd Add a GZIP test for the empty payload.
R=rsc, r
CC=golang-dev
https://golang.org/cl/194131
2010-01-30 11:54:39 +11:00
Nigel Tao
c9150003a9 gzip deflater (i.e., writer).
Also, the unused Inflater.eof field was removed.
It has been unused since revision aaa0b24538.
"introduce os.EOF and io.ErrUnexpectedEOF. remove io.ErrEOF."
http://code.google.com/p/go/source/diff?spec=svnaaa0b24538ed1e3e54cbbfdd030a3c35785e74c5&r=aaa0b24538ed1e3e54cbbfdd030a3c35785e74c5&format=side&path=/src/pkg/compress/gzip/gunzip.go

R=rsc
CC=golang-dev
https://golang.org/cl/194122
2010-01-29 11:00:05 +11:00
Russ Cox
14ccf44fc7 compress/zlib: add example to doc comment
Fixes #548.

R=r
CC=golang-dev, graycardinalster
https://golang.org/cl/190062
2010-01-19 13:09:50 -08:00
Robert Griesemer
5a1d3323fe 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

	       1st set of files.

R=rsc
CC=agl, golang-dev, iant, ken2, r
https://golang.org/cl/180047
2009-12-15 15:33:31 -08:00
Robert Griesemer
295ceb4526 remove uses of string concatenation from src and misc directory
R=rsc
https://golang.org/cl/172041
2009-12-09 16:54:07 -08:00
Rob Pike
b0683bd77a move ReadFile, WriteFile, and ReadDir into a separate io/ioutil package.
this breaks the dependency of package io on package bytes.

R=rsc
CC=golang-dev
https://golang.org/cl/163085
2009-12-02 22:02:14 -08:00
Sergio Luis O. B. Correia
6fc820729e go: makes it build for the case $GOROOT has whitespaces
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 #115.

R=rsc, dsymonds1
https://golang.org/cl/157067
2009-11-23 17:32:51 -08:00
Russ Cox
9ac4449cb2 gofmt -r 'α[β:len(α)] -> α[β:]' -w src/cmd src/pkg
R=r, gri
CC=golang-dev
https://golang.org/cl/156115
2009-11-20 11:45:05 -08:00
Rob Pike
e70cedfaec remove bytes.Copy
replace all calls with calls to copy
use copy in regexp and bytes.Buffer

R=rsc
CC=golang-dev
https://golang.org/cl/157073
2009-11-18 15:24:24 -08:00
Robert Griesemer
baba292998 - replaced gofmt expression formatting algorithm with
rsc's algorithm
	- applied gofmt -w misc src
	- partial CL (remaining files in other CLs)

R=rsc, r
http://go/go-review/1026036
2009-11-09 21:13:17 -08:00