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

5070 Commits

Author SHA1 Message Date
Brad Fitzpatrick
da6d835b90 crypto: rename some FooError to ErrFoo
Also, add an explicit error type when the right hand side is an unexported
function.

R=golang-dev, gri, rogpeppe, agl, rsc
CC=golang-dev
https://golang.org/cl/5564048
2012-01-24 08:32:43 -08:00
Gustavo Niemeyer
0442087f93 encoding/xml: bring API closer to other packages
Includes gofix module. The only case not covered should be
xml.Unmarshal, since it remains with a similar interface, and
would require introspecting the type of its first argument
better.

Fixes #2626.

R=golang-dev, rsc, gustavo
CC=golang-dev
https://golang.org/cl/5574053
2012-01-24 01:10:32 -02:00
Robert Griesemer
6d7e9382b4 go/doc: removed unused field "Type.Type"
CL 5572043 removed the last uses of this field.
The information is readily available from Type.Decl.

R=rsc, golang-dev
CC=golang-dev
https://golang.org/cl/5570049
2012-01-23 16:53:19 -08:00
David G. Andersen
1dc37bbf46 math/big: slight improvement to algorithm used for internal bitLen function
The bitLen function currently shifts out blocks of 8 bits at a time.
This change replaces this sorta-linear algorithm with a log(N)
one (shift out 16 bits, then 8, then 4, then 2, then 1).
I left the start of it linear at 16 bits at a time so that
the function continues to work with 32 or 64 bit values
without any funkiness.
The algorithm is similar to several of the nlz ("number of
leading zeros") algorithms from "Hacker's Delight" or the
"bit twiddling hacks" pages.

Doesn't make a big difference to the existing benchmarks, but
I'm using the code in a different context that calls bitLen
much more often, so it seemed worthwhile making the existing
codebase faster so that it's a better building block.

Microbenchmark results on a 64-bit Macbook Pro using 6g from weekly.2012-01-20:

benchmark                old ns/op    new ns/op    delta
big.BenchmarkBitLen0             4            6  +50.12%
big.BenchmarkBitLen1             4            6  +33.91%
big.BenchmarkBitLen2             6            6   +3.05%
big.BenchmarkBitLen3             7            6  -19.05%
big.BenchmarkBitLen4             9            6  -30.19%
big.BenchmarkBitLen5            11            6  -42.23%
big.BenchmarkBitLen8            16            6  -61.78%
big.BenchmarkBitLen9             5            6  +18.29%
big.BenchmarkBitLen16           18            7  -60.99%
big.BenchmarkBitLen17            7            6   -4.64%
big.BenchmarkBitLen31           19            7  -62.49%

On an ARM machine (with the previous weekly):

benchmark                old ns/op    new ns/op    delta
big.BenchmarkBitLen0            37           50  +36.56%
big.BenchmarkBitLen1            59           51  -13.69%
big.BenchmarkBitLen2            74           59  -20.40%
big.BenchmarkBitLen3            92           60  -34.89%
big.BenchmarkBitLen4           110           59  -46.09%
big.BenchmarkBitLen5           127           60  -52.68%
big.BenchmarkBitLen8           181           59  -67.24%
big.BenchmarkBitLen9            78           60  -23.05%
big.BenchmarkBitLen16          199           69  -65.13%
big.BenchmarkBitLen17           91           70  -23.17%
big.BenchmarkBitLen31          210           95  -54.43%

R=golang-dev, dave, edsrzf, gri
CC=golang-dev
https://golang.org/cl/5570044
2012-01-23 13:46:28 -08:00
Russ Cox
4417bc3742 exp/ebnflint: test spec during 'go test'
This avoids the need for a custom Makefile.

R=gri
CC=golang-dev
https://golang.org/cl/5575045
2012-01-23 16:35:25 -05:00
Russ Cox
b5777571b3 go/build: add BuildTags to Context, allow !tag
This lets the client of go/build specify additional tags that
can be recognized in a // +build directive.  For example,
a build for a custom environment like App Engine might
include "appengine" in the BuildTags list, so that packages
can be written with some files saying

        // +build appengine   (build only on app engine)

or

        // +build !appengine  (build only when NOT on app engine)

App Engine here is just a hypothetical context.  I plan to use
this in the cmd/go sources to distinguish the bootstrap version
of cmd/go (which will not use networking) from the full version
using a custom tag.  It might also be useful in App Engine.

Also, delete Build and Script, which we did not end up using for
cmd/go and which never got turned on for real in goinstall.

R=r, adg
CC=golang-dev
https://golang.org/cl/5554079
2012-01-23 15:16:38 -05:00
Robert Griesemer
370f4e49cd go/doc: test all operation modes
Golden files have extension .d.golden where d is the mode value (0 or 1 for now)
(i.e., testdata/file.out is now testdata/file.0.golden, and there is a new file
testdata/file.1.golden for each testcase)

R=rsc
CC=golang-dev
https://golang.org/cl/5573046
2012-01-23 10:41:54 -08:00
Marcel van Lohuizen
110964ac81 exp/norm: fixes a subtle bug introduced by change 10087: random offset
for map iteration.  New code makes table output predictable and fixes
bug.

R=rsc, r
CC=golang-dev
https://golang.org/cl/5573044
2012-01-23 19:36:52 +01:00
Mikio Hara
77cb8956a0 net: consistent OpError message
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5562047
2012-01-24 02:59:43 +09:00
Rob Pike
a937bff52c gob: annotate debug.go so it's not normally built
So it's not included in the package by the go tool.

R=iant, fullung, rsc
CC=golang-dev
https://golang.org/cl/5563049
2012-01-23 08:40:34 -08:00
Ivan Krasin
858f0b4d95 compress/flate: delete unused util functions.
R=rsc
CC=golang-dev
https://golang.org/cl/5555071
2012-01-23 10:31:51 -05:00
Ivan Krasin
b35cef6704 compress/flate: use append instead of slice+counter.
R=rsc, nigeltao
CC=golang-dev
https://golang.org/cl/5561056
2012-01-23 09:26:14 -05:00
Ivan Krasin
d7e34051fc compress/flate: reduce memory pressure at cost of additional arithmetic operation.
R=rsc
CC=golang-dev
https://golang.org/cl/5555070
2012-01-23 09:19:39 -05:00
Gustavo Niemeyer
5fde5cd5cb encoding/xml: support ignoring fields with "-"
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5564045
2012-01-23 01:34:35 -02:00
Gustavo Niemeyer
fd9c99511e encoding/xml: minor doc fixup
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5564046
2012-01-23 01:32:07 -02:00
Robert Griesemer
abd5bd7d54 go/doc: add more test cases
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5571043
2012-01-22 18:53:18 -08:00
Robert Griesemer
e37792191f go/doc: set Type.Name field
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5569043
2012-01-22 18:52:38 -08:00
Gustavo Niemeyer
57007fe12b encoding/xml: improve []byte handling
Marshalling of []byte in attributes and the general
marshalling of named []byte types was fixed.

A []byte field also won't be nil if an XML element
was mapped to it, even if the element is empty.

Tests were introduced to make sure that *struct{}
fields works correctly for element presence testing.
No changes to the logic made in that regard.

R=rsc
CC=golang-dev
https://golang.org/cl/5539070
2012-01-23 00:50:05 -02:00
Andrew Gerrand
191873981a go/build: silence all warnings
R=rsc
CC=golang-dev
https://golang.org/cl/5529055
2012-01-23 09:26:46 +11:00
Rob Pike
6e1c0df104 gob: reduce the maximum message size
It was 2^31, but that could cause overflow and trouble.
Reduce it to 2^30 and add a TODO.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/5562049
2012-01-22 12:01:12 -08:00
Shenghou Ma
e021357673 runtime: update out-of-date comment
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5532118
2012-01-22 10:34:17 -08: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
Ivan Krasin
4d3b9d9757 compress/flate: fix a typo, improve compression rate by 3-4%.
R=rsc
CC=golang-dev
https://golang.org/cl/5556077
2012-01-21 12:18:15 -05:00
Mikio Hara
68daa41d1b net: Dial, ListenPacket with "ip:protocol" network for raw IP sockets
Fixes #2654.

R=rsc
CC=golang-dev
https://golang.org/cl/5545058
2012-01-21 21:51:53 +09:00
Ivan Krasin
c4b16a3864 compress/flate: make lazy matching work.
R=rsc, imkrasin
CC=golang-dev
https://golang.org/cl/5554066
2012-01-20 23:35:18 -05:00
Anthony Martin
fb3b27329e os: fix Plan 9 build after more FileMode changes
This should go in after Brad's CL 5553064.

R=bradfitz, rsc
CC=golang-dev
https://golang.org/cl/5555056
2012-01-20 20:01:29 -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
Robert Griesemer
0796c1c3ec encoding/varint: deleted WriteXvarint
Fixes #2748.

R=rsc, r, r
CC=golang-dev
https://golang.org/cl/5557072
2012-01-20 12:57:53 -08:00
Scott Lawrence
b0360e469c go/ast: respect ImportSpec.EndPos
Fixes #2566.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5541068
2012-01-20 13:34:19 -05:00
Russ Cox
88010973aa go/doc: avoid the name 'a.out' in the testdata
R=golang-dev, gri, r
CC=golang-dev
https://golang.org/cl/5561047
2012-01-20 13:34:11 -05:00
Dmitriy Vyukov
1ff1405cc7 runtime: add type algorithms for zero-sized types
BenchmarkChanSem old=127ns new=78.6ns

R=golang-dev, bradfitz, sameer, rsc
CC=golang-dev
https://golang.org/cl/5558049
2012-01-20 10:32:55 +04:00
Mikio Hara
5e59e8537c net: fix linux build
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5558056
2012-01-19 18:56:17 -08:00
Alex Brainman
8d6958fc04 misc/cgo/test: make tests run on windows
- use proper Win64 gcc calling convention when
  calling initcgo on amd64
- increase g0 stack size to 64K on amd64 to make
  it the same as 386
- implement C.sleep
- do not use C.stat, since it is renamed to C._stat by mingw
- use fopen to implement TestErrno, since C.strtol
  always succeeds on windows
- skip TestSetEnv on windows, because os.Setenv
  sets windows process environment, while C.getenv
  inspects internal C runtime variable instead

R=golang-dev, vcc.163, rsc
CC=golang-dev
https://golang.org/cl/5500094
2012-01-20 12:59:44 +11:00
Brad Fitzpatrick
7fc4c07172 database/sql: move from exp/sql
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5536076
2012-01-19 16:04:26 -08:00
Gustavo Niemeyer
369454d7b2 html/template: fix docs after API changes
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5528109
2012-01-19 21:49:28 -02:00
Brad Fitzpatrick
6454a3eb15 os: use FileMode instead of uint32 in various functions
Fixes #2733

R=chickencha, ality, rsc
CC=golang-dev
https://golang.org/cl/5553064
2012-01-19 15:45:18 -08:00
Nigel Tao
ab2ea94c60 image: change the YCbCr image's pixel buffers to start at Rect.Min
instead of the origin.

This makes YCbCr match the other image types (e.g. RGBA, Gray) in
that an image's bounds is not restricted to the positive quadrant.

Also optimize the YCbCr draw code by hoisting some computation
outside of the loop.

benchmark              old ns/op    new ns/op    delta
draw.BenchmarkYCbCr      2544418      2373558   -6.72%

Like https://golang.org/cl/4681044/ I don't think a gofix is
feasible. People will have to make manual changes. On the other hand,
directly manipulating YCbCr images is relatively rare, compared to
RGBA images, and if other code just uses the jpeg and draw packages
instead of messing directly with a YCbCr's []byte representations,
then things should just continue to work.

R=r
CC=golang-dev
https://golang.org/cl/5558048
2012-01-20 10:44:22 +11:00
Mikio Hara
7f4936a1c5 net: fix windows build
R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/5532102
2012-01-20 08:33:37 +09:00
Mikio Hara
743c2d0f48 net: fix broken setDefaultSockopts
R=rsc, bradfitz
CC=golang-dev
https://golang.org/cl/5536068
2012-01-20 07:31:13 +09:00
Luit van Drongelen
8d66a416cb crypto/hmac: Deprecate hmac.NewMD5, hmac.NewSHA1 and hmac.NewSHA256
Remove NewMD5, NewSHA1 and NewSHA256 in favor of using New and
explicitly importing the used hash-function. This way when using, for
example, HMAC with RIPEMD there's no md5, sha1 and sha256 linked in
through the hmac package.

A gofix rule is included, and applied to the standard library (3 files
altered).

This change is the result of a discussion at
https://golang.org/cl/5550043/ to pull the discussion about
deprecating these functions out of that issue.

R=golang-dev, agl
CC=golang-dev, r, rsc
https://golang.org/cl/5556058
2012-01-19 17:28:38 -05:00
David Symonds
ee09a8cd9f gc: don't emit pkgpath for error type.
Fixes #2660.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5557060
2012-01-20 09:26:17 +11:00
Brad Fitzpatrick
bb7eca177a net/http: log handler panic before closing HTTP connection
Fix originally from rogpeppe in 5414048 but was rolled
back due to test breakage.

This CL makes the test more robust to order of operations.

Fixes #2480 again.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5536072
2012-01-19 14:19:59 -08:00
Gustavo Niemeyer
01a0d39a7f os/exec: trivial allocation removal in LookPath
R=golang-dev, bsiegert, r
CC=golang-dev
https://golang.org/cl/5549043
2012-01-19 20:17:46 -02:00
Gustavo Niemeyer
ca3e6d1367 encoding/xml: marshal/unmarshal xml.Name in field
R=rsc
CC=golang-dev
https://golang.org/cl/5542052
2012-01-19 20:15:55 -02:00
Shenghou Ma
fec7aa952f doc: update out-of-date comments about runtime/cgo
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5532100
2012-01-19 17:13:33 -05:00
Robert Griesemer
7b07310a69 go/parser: expressions may have comments
Thanks to 0xE2.0x9A.0x9B for the patch suggestion.

Fixes #2739.

R=r
CC=golang-dev
https://golang.org/cl/5536071
2012-01-19 13:54:31 -08:00
Rob Pike
c837e612bd text/template/parse: use human error prints
The previous version of all the node.String methods printed the parse
tree and was useful for developing the parse tree code. Now that that's done,
we might as well print the nodes using the standard template syntax.
It's much easier to read and makes error reporting look more natural.

Helps issue 2644.

R=rsc, n13m3y3r
CC=golang-dev
https://golang.org/cl/5553066
2012-01-19 13:51:37 -08:00