diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-03-30 15:33:16 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-03-30 15:33:16 +0000 |
commit | f72f4169133572cf62f1e872c5657cdbc4d5de2c (patch) | |
tree | 9382d76e5dc68294cdf3c4f2c03a9f61b44fb014 /libgo/go/bytes | |
parent | f2034d064c29d9620c5562b2b5b517bdc6c7a672 (diff) | |
download | gcc-f72f4169133572cf62f1e872c5657cdbc4d5de2c.zip gcc-f72f4169133572cf62f1e872c5657cdbc4d5de2c.tar.gz gcc-f72f4169133572cf62f1e872c5657cdbc4d5de2c.tar.bz2 |
Update to current Go library.
From-SVN: r171732
Diffstat (limited to 'libgo/go/bytes')
-rw-r--r-- | libgo/go/bytes/buffer_test.go | 12 | ||||
-rw-r--r-- | libgo/go/bytes/bytes.go | 18 | ||||
-rw-r--r-- | libgo/go/bytes/bytes_test.go | 5 |
3 files changed, 18 insertions, 17 deletions
diff --git a/libgo/go/bytes/buffer_test.go b/libgo/go/bytes/buffer_test.go index 56a2d92..14f9501 100644 --- a/libgo/go/bytes/buffer_test.go +++ b/libgo/go/bytes/buffer_test.go @@ -178,7 +178,11 @@ func TestBasicOperations(t *testing.T) { func TestLargeStringWrites(t *testing.T) { var buf Buffer - for i := 3; i < 30; i += 3 { + limit := 30 + if testing.Short() { + limit = 9 + } + for i := 3; i < limit; i += 3 { s := fillString(t, "TestLargeWrites (1)", &buf, "", 5, data) empty(t, "TestLargeStringWrites (2)", &buf, s, make([]byte, len(data)/i)) } @@ -188,7 +192,11 @@ func TestLargeStringWrites(t *testing.T) { func TestLargeByteWrites(t *testing.T) { var buf Buffer - for i := 3; i < 30; i += 3 { + limit := 30 + if testing.Short() { + limit = 9 + } + for i := 3; i < limit; i += 3 { s := fillBytes(t, "TestLargeWrites (1)", &buf, "", 5, bytes) empty(t, "TestLargeByteWrites (2)", &buf, s, make([]byte, len(data)/i)) } diff --git a/libgo/go/bytes/bytes.go b/libgo/go/bytes/bytes.go index bfe2ef3..c12a135 100644 --- a/libgo/go/bytes/bytes.go +++ b/libgo/go/bytes/bytes.go @@ -293,20 +293,10 @@ func Join(a [][]byte, sep []byte) []byte { } b := make([]byte, n) - bp := 0 - for i := 0; i < len(a); i++ { - s := a[i] - for j := 0; j < len(s); j++ { - b[bp] = s[j] - bp++ - } - if i+1 < len(a) { - s = sep - for j := 0; j < len(s); j++ { - b[bp] = s[j] - bp++ - } - } + bp := copy(b, a[0]) + for _, s := range a[1:] { + bp += copy(b[bp:], sep) + bp += copy(b[bp:], s) } return b } diff --git a/libgo/go/bytes/bytes_test.go b/libgo/go/bytes/bytes_test.go index 063686e..4ce291a 100644 --- a/libgo/go/bytes/bytes_test.go +++ b/libgo/go/bytes/bytes_test.go @@ -201,7 +201,10 @@ func TestIndexByte(t *testing.T) { // test a larger buffer with different sizes and alignments func TestIndexByteBig(t *testing.T) { - const n = 1024 + var n = 1024 + if testing.Short() { + n = 128 + } b := make([]byte, n) for i := 0; i < n; i++ { // different start alignments |