Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
d86ab015
Commit
d86ab015
authored
Oct 26, 2010
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use copy
R=gri CC=golang-dev
https://golang.org/cl/2763041
parent
e48c0fb5
Changes
45
Hide whitespace changes
Inline
Side-by-side
Showing
45 changed files
with
68 additions
and
199 deletions
+68
-199
src/pkg/archive/tar/writer.go
src/pkg/archive/tar/writer.go
+1
-3
src/pkg/bufio/bufio.go
src/pkg/bufio/bufio.go
+1
-3
src/pkg/bufio/bufio_test.go
src/pkg/bufio/bufio_test.go
+1
-4
src/pkg/bytes/buffer.go
src/pkg/bytes/buffer.go
+2
-13
src/pkg/bytes/buffer_test.go
src/pkg/bytes/buffer_test.go
+2
-2
src/pkg/bytes/bytes.go
src/pkg/bytes/bytes.go
+1
-3
src/pkg/bytes/bytes_test.go
src/pkg/bytes/bytes_test.go
+7
-19
src/pkg/crypto/block/cbc.go
src/pkg/crypto/block/cbc.go
+1
-1
src/pkg/crypto/block/cfb.go
src/pkg/crypto/block/cfb.go
+1
-1
src/pkg/crypto/block/cipher.go
src/pkg/crypto/block/cipher.go
+2
-4
src/pkg/crypto/block/ctr.go
src/pkg/crypto/block/ctr.go
+1
-1
src/pkg/crypto/block/eax.go
src/pkg/crypto/block/eax.go
+4
-4
src/pkg/crypto/block/ecb.go
src/pkg/crypto/block/ecb.go
+2
-8
src/pkg/crypto/block/ofb.go
src/pkg/crypto/block/ofb.go
+1
-1
src/pkg/crypto/md4/md4.go
src/pkg/crypto/md4/md4.go
+1
-4
src/pkg/crypto/md5/md5.go
src/pkg/crypto/md5/md5.go
+1
-4
src/pkg/crypto/ripemd160/ripemd160.go
src/pkg/crypto/ripemd160/ripemd160.go
+1
-4
src/pkg/crypto/sha1/sha1.go
src/pkg/crypto/sha1/sha1.go
+1
-4
src/pkg/crypto/sha256/sha256.go
src/pkg/crypto/sha256/sha256.go
+1
-4
src/pkg/crypto/sha512/sha512.go
src/pkg/crypto/sha512/sha512.go
+1
-4
src/pkg/crypto/x509/x509.go
src/pkg/crypto/x509/x509.go
+1
-3
src/pkg/debug/dwarf/type.go
src/pkg/debug/dwarf/type.go
+3
-9
src/pkg/debug/macho/file.go
src/pkg/debug/macho/file.go
+1
-3
src/pkg/exp/4s/4s.go
src/pkg/exp/4s/4s.go
+1
-3
src/pkg/exp/eval/expr.go
src/pkg/exp/eval/expr.go
+2
-6
src/pkg/exp/eval/func.go
src/pkg/exp/eval/func.go
+2
-6
src/pkg/exp/eval/type.go
src/pkg/exp/eval/type.go
+1
-3
src/pkg/exp/nacl/srpc/msg.go
src/pkg/exp/nacl/srpc/msg.go
+2
-6
src/pkg/exp/nacl/srpc/server.go
src/pkg/exp/nacl/srpc/server.go
+1
-3
src/pkg/exp/ogle/process.go
src/pkg/exp/ogle/process.go
+1
-3
src/pkg/go/doc/doc.go
src/pkg/go/doc/doc.go
+3
-5
src/pkg/net/dnsmsg.go
src/pkg/net/dnsmsg.go
+1
-4
src/pkg/os/dir_darwin.go
src/pkg/os/dir_darwin.go
+1
-3
src/pkg/os/dir_freebsd.go
src/pkg/os/dir_freebsd.go
+1
-3
src/pkg/os/dir_linux.go
src/pkg/os/dir_linux.go
+1
-3
src/pkg/os/dir_nacl.go
src/pkg/os/dir_nacl.go
+1
-3
src/pkg/os/env_windows.go
src/pkg/os/env_windows.go
+1
-3
src/pkg/os/file_windows.go
src/pkg/os/file_windows.go
+1
-3
src/pkg/scanner/scanner_test.go
src/pkg/scanner/scanner_test.go
+1
-4
src/pkg/strings/strings.go
src/pkg/strings/strings.go
+3
-14
src/pkg/syscall/syscall.go
src/pkg/syscall/syscall.go
+1
-3
src/pkg/template/template.go
src/pkg/template/template.go
+1
-3
src/pkg/testing/regexp.go
src/pkg/testing/regexp.go
+2
-6
src/pkg/unicode/maketables.go
src/pkg/unicode/maketables.go
+1
-3
src/pkg/xml/xml.go
src/pkg/xml/xml.go
+1
-3
No files found.
src/pkg/archive/tar/writer.go
View file @
d86ab015
...
@@ -71,9 +71,7 @@ func (tw *Writer) cString(b []byte, s string) {
...
@@ -71,9 +71,7 @@ func (tw *Writer) cString(b []byte, s string) {
}
}
return
return
}
}
for
i
,
ch
:=
range
[]
byte
(
s
)
{
copy
(
b
,
s
)
b
[
i
]
=
ch
}
if
len
(
s
)
<
len
(
b
)
{
if
len
(
s
)
<
len
(
b
)
{
b
[
len
(
s
)]
=
0
b
[
len
(
s
)]
=
0
}
}
...
...
src/pkg/bufio/bufio.go
View file @
d86ab015
...
@@ -316,9 +316,7 @@ func (b *Reader) ReadBytes(delim byte) (line []byte, err os.Error) {
...
@@ -316,9 +316,7 @@ func (b *Reader) ReadBytes(delim byte) (line []byte, err os.Error) {
full
=
make
([][]
byte
,
16
)
full
=
make
([][]
byte
,
16
)
}
else
if
nfull
>=
len
(
full
)
{
}
else
if
nfull
>=
len
(
full
)
{
newfull
:=
make
([][]
byte
,
len
(
full
)
*
2
)
newfull
:=
make
([][]
byte
,
len
(
full
)
*
2
)
for
i
:=
0
;
i
<
len
(
full
);
i
++
{
copy
(
newfull
,
full
)
newfull
[
i
]
=
full
[
i
]
}
full
=
newfull
full
=
newfull
}
}
...
...
src/pkg/bufio/bufio_test.go
View file @
d86ab015
...
@@ -179,10 +179,7 @@ type StringReader struct {
...
@@ -179,10 +179,7 @@ type StringReader struct {
func
(
r
*
StringReader
)
Read
(
p
[]
byte
)
(
n
int
,
err
os
.
Error
)
{
func
(
r
*
StringReader
)
Read
(
p
[]
byte
)
(
n
int
,
err
os
.
Error
)
{
if
r
.
step
<
len
(
r
.
data
)
{
if
r
.
step
<
len
(
r
.
data
)
{
s
:=
r
.
data
[
r
.
step
]
s
:=
r
.
data
[
r
.
step
]
for
i
:=
0
;
i
<
len
(
s
);
i
++
{
n
=
copy
(
p
,
s
)
p
[
i
]
=
s
[
i
]
}
n
=
len
(
s
)
r
.
step
++
r
.
step
++
}
else
{
}
else
{
err
=
os
.
EOF
err
=
os
.
EOF
...
...
src/pkg/bytes/buffer.go
View file @
d86ab015
...
@@ -12,14 +12,6 @@ import (
...
@@ -12,14 +12,6 @@ import (
"utf8"
"utf8"
)
)
// Copy from string to byte array at offset doff. Assume there's room.
func
copyString
(
dst
[]
byte
,
doff
int
,
str
string
)
{
for
soff
:=
0
;
soff
<
len
(
str
);
soff
++
{
dst
[
doff
]
=
str
[
soff
]
doff
++
}
}
// A Buffer is a variable-sized buffer of bytes with Read and Write methods.
// A Buffer is a variable-sized buffer of bytes with Read and Write methods.
// The zero value for Buffer is an empty buffer ready to use.
// The zero value for Buffer is an empty buffer ready to use.
type
Buffer
struct
{
type
Buffer
struct
{
...
@@ -99,8 +91,7 @@ func (b *Buffer) Write(p []byte) (n int, err os.Error) {
...
@@ -99,8 +91,7 @@ func (b *Buffer) Write(p []byte) (n int, err os.Error) {
// value n is the length of s; err is always nil.
// value n is the length of s; err is always nil.
func
(
b
*
Buffer
)
WriteString
(
s
string
)
(
n
int
,
err
os
.
Error
)
{
func
(
b
*
Buffer
)
WriteString
(
s
string
)
(
n
int
,
err
os
.
Error
)
{
m
:=
b
.
grow
(
len
(
s
))
m
:=
b
.
grow
(
len
(
s
))
copyString
(
b
.
buf
,
m
,
s
)
return
copy
(
b
.
buf
[
m
:
],
s
),
nil
return
len
(
s
),
nil
}
}
// MinRead is the minimum slice size passed to a Read call by
// MinRead is the minimum slice size passed to a Read call by
...
@@ -259,7 +250,5 @@ func NewBuffer(buf []byte) *Buffer { return &Buffer{buf: buf} }
...
@@ -259,7 +250,5 @@ func NewBuffer(buf []byte) *Buffer { return &Buffer{buf: buf} }
// initial contents. It is intended to prepare a buffer to read an existing
// initial contents. It is intended to prepare a buffer to read an existing
// string.
// string.
func
NewBufferString
(
s
string
)
*
Buffer
{
func
NewBufferString
(
s
string
)
*
Buffer
{
buf
:=
make
([]
byte
,
len
(
s
))
return
&
Buffer
{
buf
:
[]
byte
(
s
)}
copyString
(
buf
,
0
,
s
)
return
&
Buffer
{
buf
:
buf
}
}
}
src/pkg/bytes/buffer_test.go
View file @
d86ab015
...
@@ -132,7 +132,7 @@ func TestBasicOperations(t *testing.T) {
...
@@ -132,7 +132,7 @@ func TestBasicOperations(t *testing.T) {
buf
.
Truncate
(
0
)
buf
.
Truncate
(
0
)
check
(
t
,
"TestBasicOperations (3)"
,
&
buf
,
""
)
check
(
t
,
"TestBasicOperations (3)"
,
&
buf
,
""
)
n
,
err
:=
buf
.
Write
(
Bytes
(
data
[
0
:
1
]))
n
,
err
:=
buf
.
Write
(
[]
byte
(
data
[
0
:
1
]))
if
n
!=
1
{
if
n
!=
1
{
t
.
Errorf
(
"wrote 1 byte, but n == %d"
,
n
)
t
.
Errorf
(
"wrote 1 byte, but n == %d"
,
n
)
}
}
...
@@ -144,7 +144,7 @@ func TestBasicOperations(t *testing.T) {
...
@@ -144,7 +144,7 @@ func TestBasicOperations(t *testing.T) {
buf
.
WriteByte
(
data
[
1
])
buf
.
WriteByte
(
data
[
1
])
check
(
t
,
"TestBasicOperations (5)"
,
&
buf
,
"ab"
)
check
(
t
,
"TestBasicOperations (5)"
,
&
buf
,
"ab"
)
n
,
err
=
buf
.
Write
(
Bytes
(
data
[
2
:
26
]))
n
,
err
=
buf
.
Write
(
[]
byte
(
data
[
2
:
26
]))
if
n
!=
24
{
if
n
!=
24
{
t
.
Errorf
(
"wrote 25 bytes, but n == %d"
,
n
)
t
.
Errorf
(
"wrote 25 bytes, but n == %d"
,
n
)
}
}
...
...
src/pkg/bytes/bytes.go
View file @
d86ab015
...
@@ -325,9 +325,7 @@ func Map(mapping func(rune int) int, s []byte) []byte {
...
@@ -325,9 +325,7 @@ func Map(mapping func(rune int) int, s []byte) []byte {
// Grow the buffer.
// Grow the buffer.
maxbytes
=
maxbytes
*
2
+
utf8
.
UTFMax
maxbytes
=
maxbytes
*
2
+
utf8
.
UTFMax
nb
:=
make
([]
byte
,
maxbytes
)
nb
:=
make
([]
byte
,
maxbytes
)
for
i
,
c
:=
range
b
[
0
:
nbytes
]
{
copy
(
nb
,
b
[
0
:
nbytes
])
nb
[
i
]
=
c
}
b
=
nb
b
=
nb
}
}
nbytes
+=
utf8
.
EncodeRune
(
rune
,
b
[
nbytes
:
maxbytes
])
nbytes
+=
utf8
.
EncodeRune
(
rune
,
b
[
nbytes
:
maxbytes
])
...
...
src/pkg/bytes/bytes_test.go
View file @
d86ab015
...
@@ -416,21 +416,11 @@ var trimSpaceTests = []StringTest{
...
@@ -416,21 +416,11 @@ var trimSpaceTests = []StringTest{
{
"x ☺ "
,
"x ☺"
},
{
"x ☺ "
,
"x ☺"
},
}
}
// Bytes returns a new slice containing the bytes in s.
// Borrowed from strings to avoid dependency.
func
Bytes
(
s
string
)
[]
byte
{
b
:=
make
([]
byte
,
len
(
s
))
for
i
:=
0
;
i
<
len
(
s
);
i
++
{
b
[
i
]
=
s
[
i
]
}
return
b
}
// Execute f on each test case. funcName should be the name of f; it's used
// Execute f on each test case. funcName should be the name of f; it's used
// in failure reports.
// in failure reports.
func
runStringTests
(
t
*
testing
.
T
,
f
func
([]
byte
)
[]
byte
,
funcName
string
,
testCases
[]
StringTest
)
{
func
runStringTests
(
t
*
testing
.
T
,
f
func
([]
byte
)
[]
byte
,
funcName
string
,
testCases
[]
StringTest
)
{
for
_
,
tc
:=
range
testCases
{
for
_
,
tc
:=
range
testCases
{
actual
:=
string
(
f
(
Bytes
(
tc
.
in
)))
actual
:=
string
(
f
(
[]
byte
(
tc
.
in
)))
if
actual
!=
tc
.
out
{
if
actual
!=
tc
.
out
{
t
.
Errorf
(
"%s(%q) = %q; want %q"
,
funcName
,
tc
.
in
,
actual
,
tc
.
out
)
t
.
Errorf
(
"%s(%q) = %q; want %q"
,
funcName
,
tc
.
in
,
actual
,
tc
.
out
)
}
}
...
@@ -463,7 +453,7 @@ func TestMap(t *testing.T) {
...
@@ -463,7 +453,7 @@ func TestMap(t *testing.T) {
// 1. Grow. This triggers two reallocations in Map.
// 1. Grow. This triggers two reallocations in Map.
maxRune
:=
func
(
rune
int
)
int
{
return
unicode
.
MaxRune
}
maxRune
:=
func
(
rune
int
)
int
{
return
unicode
.
MaxRune
}
m
:=
Map
(
maxRune
,
Bytes
(
a
))
m
:=
Map
(
maxRune
,
[]
byte
(
a
))
expect
:=
tenRunes
(
unicode
.
MaxRune
)
expect
:=
tenRunes
(
unicode
.
MaxRune
)
if
string
(
m
)
!=
expect
{
if
string
(
m
)
!=
expect
{
t
.
Errorf
(
"growing: expected %q got %q"
,
expect
,
m
)
t
.
Errorf
(
"growing: expected %q got %q"
,
expect
,
m
)
...
@@ -471,21 +461,21 @@ func TestMap(t *testing.T) {
...
@@ -471,21 +461,21 @@ func TestMap(t *testing.T) {
// 2. Shrink
// 2. Shrink
minRune
:=
func
(
rune
int
)
int
{
return
'a'
}
minRune
:=
func
(
rune
int
)
int
{
return
'a'
}
m
=
Map
(
minRune
,
Bytes
(
tenRunes
(
unicode
.
MaxRune
)))
m
=
Map
(
minRune
,
[]
byte
(
tenRunes
(
unicode
.
MaxRune
)))
expect
=
a
expect
=
a
if
string
(
m
)
!=
expect
{
if
string
(
m
)
!=
expect
{
t
.
Errorf
(
"shrinking: expected %q got %q"
,
expect
,
m
)
t
.
Errorf
(
"shrinking: expected %q got %q"
,
expect
,
m
)
}
}
// 3. Rot13
// 3. Rot13
m
=
Map
(
rot13
,
Bytes
(
"a to zed"
))
m
=
Map
(
rot13
,
[]
byte
(
"a to zed"
))
expect
=
"n gb mrq"
expect
=
"n gb mrq"
if
string
(
m
)
!=
expect
{
if
string
(
m
)
!=
expect
{
t
.
Errorf
(
"rot13: expected %q got %q"
,
expect
,
m
)
t
.
Errorf
(
"rot13: expected %q got %q"
,
expect
,
m
)
}
}
// 4. Rot13^2
// 4. Rot13^2
m
=
Map
(
rot13
,
Map
(
rot13
,
Bytes
(
"a to zed"
)))
m
=
Map
(
rot13
,
Map
(
rot13
,
[]
byte
(
"a to zed"
)))
expect
=
"a to zed"
expect
=
"a to zed"
if
string
(
m
)
!=
expect
{
if
string
(
m
)
!=
expect
{
t
.
Errorf
(
"rot13: expected %q got %q"
,
expect
,
m
)
t
.
Errorf
(
"rot13: expected %q got %q"
,
expect
,
m
)
...
@@ -498,7 +488,7 @@ func TestMap(t *testing.T) {
...
@@ -498,7 +488,7 @@ func TestMap(t *testing.T) {
}
}
return
-
1
return
-
1
}
}
m
=
Map
(
dropNotLatin
,
Bytes
(
"Hello, 세계"
))
m
=
Map
(
dropNotLatin
,
[]
byte
(
"Hello, 세계"
))
expect
=
"Hello"
expect
=
"Hello"
if
string
(
m
)
!=
expect
{
if
string
(
m
)
!=
expect
{
t
.
Errorf
(
"drop: expected %q got %q"
,
expect
,
m
)
t
.
Errorf
(
"drop: expected %q got %q"
,
expect
,
m
)
...
@@ -526,9 +516,7 @@ var addtests = []AddTest{
...
@@ -526,9 +516,7 @@ var addtests = []AddTest{
func
TestAdd
(
t
*
testing
.
T
)
{
func
TestAdd
(
t
*
testing
.
T
)
{
for
_
,
test
:=
range
addtests
{
for
_
,
test
:=
range
addtests
{
b
:=
make
([]
byte
,
len
(
test
.
s
),
test
.
cap
)
b
:=
make
([]
byte
,
len
(
test
.
s
),
test
.
cap
)
for
i
:=
0
;
i
<
len
(
test
.
s
);
i
++
{
copy
(
b
,
test
.
s
)
b
[
i
]
=
test
.
s
[
i
]
}
b
=
Add
(
b
,
[]
byte
(
test
.
t
))
b
=
Add
(
b
,
[]
byte
(
test
.
t
))
if
string
(
b
)
!=
test
.
s
+
test
.
t
{
if
string
(
b
)
!=
test
.
s
+
test
.
t
{
t
.
Errorf
(
"Add(%q,%q) = %q"
,
test
.
s
,
test
.
t
,
string
(
b
))
t
.
Errorf
(
"Add(%q,%q) = %q"
,
test
.
s
,
test
.
t
,
string
(
b
))
...
...
src/pkg/crypto/block/cbc.go
View file @
d86ab015
...
@@ -27,7 +27,7 @@ func newCBC(c Cipher, iv []byte) *cbcCipher {
...
@@ -27,7 +27,7 @@ func newCBC(c Cipher, iv []byte) *cbcCipher {
x
:=
new
(
cbcCipher
)
x
:=
new
(
cbcCipher
)
x
.
c
=
c
x
.
c
=
c
x
.
blockSize
=
n
x
.
blockSize
=
n
x
.
iv
=
copy
(
iv
)
x
.
iv
=
dup
(
iv
)
x
.
tmp
=
make
([]
byte
,
n
)
x
.
tmp
=
make
([]
byte
,
n
)
return
x
return
x
}
}
...
...
src/pkg/crypto/block/cfb.go
View file @
d86ab015
...
@@ -33,7 +33,7 @@ func newCFB(c Cipher, s int, iv []byte) *cfbCipher {
...
@@ -33,7 +33,7 @@ func newCFB(c Cipher, s int, iv []byte) *cfbCipher {
x
.
c
=
c
x
.
c
=
c
x
.
blockSize
=
s
/
8
x
.
blockSize
=
s
/
8
x
.
cipherSize
=
b
x
.
cipherSize
=
b
x
.
iv
=
copy
(
iv
)
x
.
iv
=
dup
(
iv
)
x
.
tmp
=
make
([]
byte
,
b
)
x
.
tmp
=
make
([]
byte
,
b
)
return
x
return
x
}
}
...
...
src/pkg/crypto/block/cipher.go
View file @
d86ab015
...
@@ -49,10 +49,8 @@ func same(p, q []byte) bool {
...
@@ -49,10 +49,8 @@ func same(p, q []byte) bool {
return
true
return
true
}
}
func
copy
(
p
[]
byte
)
[]
byte
{
func
dup
(
p
[]
byte
)
[]
byte
{
q
:=
make
([]
byte
,
len
(
p
))
q
:=
make
([]
byte
,
len
(
p
))
for
i
,
b
:=
range
p
{
copy
(
q
,
p
)
q
[
i
]
=
b
}
return
q
return
q
}
}
src/pkg/crypto/block/ctr.go
View file @
d86ab015
...
@@ -25,7 +25,7 @@ type ctrStream struct {
...
@@ -25,7 +25,7 @@ type ctrStream struct {
func
newCTRStream
(
c
Cipher
,
ctr
[]
byte
)
*
ctrStream
{
func
newCTRStream
(
c
Cipher
,
ctr
[]
byte
)
*
ctrStream
{
x
:=
new
(
ctrStream
)
x
:=
new
(
ctrStream
)
x
.
c
=
c
x
.
c
=
c
x
.
ctr
=
copy
(
ctr
)
x
.
ctr
=
dup
(
ctr
)
x
.
out
=
make
([]
byte
,
len
(
ctr
))
x
.
out
=
make
([]
byte
,
len
(
ctr
))
return
x
return
x
}
}
...
...
src/pkg/crypto/block/eax.go
View file @
d86ab015
...
@@ -45,8 +45,8 @@ func setupEAX(c Cipher, iv, hdr []byte, tagBytes int) (ctrIV, tag []byte, cmac h
...
@@ -45,8 +45,8 @@ func setupEAX(c Cipher, iv, hdr []byte, tagBytes int) (ctrIV, tag []byte, cmac h
cmac
.
Write
(
buf
)
// 0
cmac
.
Write
(
buf
)
// 0
cmac
.
Write
(
iv
)
cmac
.
Write
(
iv
)
sum
:=
cmac
.
Sum
()
sum
:=
cmac
.
Sum
()
ctrIV
=
copy
(
sum
)
ctrIV
=
dup
(
sum
)
tag
=
copy
(
sum
[
0
:
tagBytes
])
tag
=
dup
(
sum
[
0
:
tagBytes
])
cmac
.
Reset
()
cmac
.
Reset
()
buf
[
n
-
1
]
=
1
buf
[
n
-
1
]
=
1
...
@@ -237,8 +237,8 @@ func (x *eaxDecrypter) checkTag() os.Error {
...
@@ -237,8 +237,8 @@ func (x *eaxDecrypter) checkTag() os.Error {
finishEAX
(
x
.
tag
,
x
.
cr
.
cmac
)
finishEAX
(
x
.
tag
,
x
.
cr
.
cmac
)
if
!
same
(
x
.
tag
,
x
.
cr
.
tag
)
{
if
!
same
(
x
.
tag
,
x
.
cr
.
tag
)
{
e
:=
new
(
EAXTagError
)
e
:=
new
(
EAXTagError
)
e
.
Computed
=
copy
(
x
.
tag
)
e
.
Computed
=
dup
(
x
.
tag
)
e
.
Read
=
copy
(
x
.
cr
.
tag
)
e
.
Read
=
dup
(
x
.
cr
.
tag
)
return
e
return
e
}
}
return
nil
return
nil
...
...
src/pkg/crypto/block/ecb.go
View file @
d86ab015
...
@@ -127,9 +127,7 @@ func (x *ecbDecrypter) Read(p []byte) (n int, err os.Error) {
...
@@ -127,9 +127,7 @@ func (x *ecbDecrypter) Read(p []byte) (n int, err os.Error) {
// Save it for next time.
// Save it for next time.
if
i
<
n
{
if
i
<
n
{
p
=
p
[
i
:
n
]
p
=
p
[
i
:
n
]
for
j
,
v
:=
range
p
{
copy
(
x
.
buf
,
p
)
x
.
buf
[
j
]
=
v
}
x
.
crypt
=
x
.
buf
[
0
:
len
(
p
)]
x
.
crypt
=
x
.
buf
[
0
:
len
(
p
)]
n
=
i
n
=
i
}
}
...
@@ -191,11 +189,7 @@ func (x *ecbEncrypter) slidePlain() {
...
@@ -191,11 +189,7 @@ func (x *ecbEncrypter) slidePlain() {
if
len
(
x
.
plain
)
==
0
{
if
len
(
x
.
plain
)
==
0
{
x
.
plain
=
x
.
buf
[
0
:
0
]
x
.
plain
=
x
.
buf
[
0
:
0
]
}
else
if
cap
(
x
.
plain
)
<
cap
(
x
.
buf
)
{
}
else
if
cap
(
x
.
plain
)
<
cap
(
x
.
buf
)
{
// plain and buf share same data,
copy
(
x
.
buf
,
x
.
plain
)
// but buf is before plain, so forward loop is correct
for
i
:=
0
;
i
<
len
(
x
.
plain
);
i
++
{
x
.
buf
[
i
]
=
x
.
plain
[
i
]
}
x
.
plain
=
x
.
buf
[
0
:
len
(
x
.
plain
)]
x
.
plain
=
x
.
buf
[
0
:
len
(
x
.
plain
)]
}
}
}
}
...
...
src/pkg/crypto/block/ofb.go
View file @
d86ab015
...
@@ -29,7 +29,7 @@ func newOFBStream(c Cipher, iv []byte) *ofbStream {
...
@@ -29,7 +29,7 @@ func newOFBStream(c Cipher, iv []byte) *ofbStream {
if
n
!=
c
.
BlockSize
()
{
if
n
!=
c
.
BlockSize
()
{
panic
(
fmt
.
Sprintln
(
"crypto/block: newOFBStream: invalid iv size"
,
n
,
"!="
,
c
.
BlockSize
()))
panic
(
fmt
.
Sprintln
(
"crypto/block: newOFBStream: invalid iv size"
,
n
,
"!="
,
c
.
BlockSize
()))
}
}
x
.
iv
=
copy
(
iv
)
x
.
iv
=
dup
(
iv
)
return
x
return
x
}
}
...
...
src/pkg/crypto/md4/md4.go
View file @
d86ab015
...
@@ -68,10 +68,7 @@ func (d *digest) Write(p []byte) (nn int, err os.Error) {
...
@@ -68,10 +68,7 @@ func (d *digest) Write(p []byte) (nn int, err os.Error) {
n
:=
_Block
(
d
,
p
)
n
:=
_Block
(
d
,
p
)
p
=
p
[
n
:
]
p
=
p
[
n
:
]
if
len
(
p
)
>
0
{
if
len
(
p
)
>
0
{
for
i
,
x
:=
range
p
{
d
.
nx
=
copy
(
d
.
x
[
:
],
p
)
d
.
x
[
i
]
=
x
}
d
.
nx
=
len
(
p
)
}
}
return
return
}
}
...
...
src/pkg/crypto/md5/md5.go
View file @
d86ab015
...
@@ -68,10 +68,7 @@ func (d *digest) Write(p []byte) (nn int, err os.Error) {
...
@@ -68,10 +68,7 @@ func (d *digest) Write(p []byte) (nn int, err os.Error) {
n
:=
_Block
(
d
,
p
)
n
:=
_Block
(
d
,
p
)
p
=
p
[
n
:
]
p
=
p
[
n
:
]
if
len
(
p
)
>
0
{
if
len
(
p
)
>
0
{
for
i
,
x
:=
range
p
{
d
.
nx
=
copy
(
d
.
x
[
:
],
p
)
d
.
x
[
i
]
=
x
}
d
.
nx
=
len
(
p
)
}
}
return
return
}
}
...
...
src/pkg/crypto/ripemd160/ripemd160.go
View file @
d86ab015
...
@@ -72,10 +72,7 @@ func (d *digest) Write(p []byte) (nn int, err os.Error) {
...
@@ -72,10 +72,7 @@ func (d *digest) Write(p []byte) (nn int, err os.Error) {
n
:=
_Block
(
d
,
p
)
n
:=
_Block
(
d
,
p
)
p
=
p
[
n
:
]
p
=
p
[
n
:
]
if
len
(
p
)
>
0
{
if
len
(
p
)
>
0
{
for
i
,
x
:=
range
p
{
d
.
nx
=
copy
(
d
.
x
[
:
],
p
)
d
.
x
[
i
]
=
x
}
d
.
nx
=
len
(
p
)
}
}
return
return
}
}
...
...
src/pkg/crypto/sha1/sha1.go
View file @
d86ab015
...
@@ -70,10 +70,7 @@ func (d *digest) Write(p []byte) (nn int, err os.Error) {
...
@@ -70,10 +70,7 @@ func (d *digest) Write(p []byte) (nn int, err os.Error) {
n
:=
_Block
(
d
,
p
)
n
:=
_Block
(
d
,
p
)
p
=
p
[
n
:
]
p
=
p
[
n
:
]
if
len
(
p
)
>
0
{
if
len
(
p
)
>
0
{
for
i
,
x
:=
range
p
{
d
.
nx
=
copy
(
d
.
x
[
:
],
p
)
d
.
x
[
i
]
=
x
}
d
.
nx
=
len
(
p
)
}
}
return
return
}
}
...
...
src/pkg/crypto/sha256/sha256.go
View file @
d86ab015
...
@@ -112,10 +112,7 @@ func (d *digest) Write(p []byte) (nn int, err os.Error) {
...
@@ -112,10 +112,7 @@ func (d *digest) Write(p []byte) (nn int, err os.Error) {
n
:=
_Block
(
d
,
p
)
n
:=
_Block
(
d
,
p
)
p
=
p
[
n
:
]
p
=
p
[
n
:
]
if
len
(
p
)
>
0
{
if
len
(
p
)
>
0
{
for
i
,
x
:=
range
p
{
d
.
nx
=
copy
(
d
.
x
[
:
],
p
)
d
.
x
[
i
]
=
x
}
d
.
nx
=
len
(
p
)
}
}
return
return
}
}
...
...
src/pkg/crypto/sha512/sha512.go
View file @
d86ab015
...
@@ -112,10 +112,7 @@ func (d *digest) Write(p []byte) (nn int, err os.Error) {
...
@@ -112,10 +112,7 @@ func (d *digest) Write(p []byte) (nn int, err os.Error) {
n
:=
_Block
(
d
,
p
)
n
:=
_Block
(
d
,
p
)
p
=
p
[
n
:
]
p
=
p
[
n
:
]
if
len
(
p
)
>
0
{
if
len
(
p
)
>
0
{
for
i
,
x
:=
range
p
{
d
.
nx
=
copy
(
d
.
x
[
:
],
p
)
d
.
x
[
i
]
=
x
}
d
.
nx
=
len
(
p
)
}
}
return
return
}
}
...
...
src/pkg/crypto/x509/x509.go
View file @
d86ab015
...
@@ -504,9 +504,7 @@ func parsePublicKey(algo PublicKeyAlgorithm, asn1Data []byte) (interface{}, os.E
...
@@ -504,9 +504,7 @@ func parsePublicKey(algo PublicKeyAlgorithm, asn1Data []byte) (interface{}, os.E
func
appendString
(
in
[]
string
,
v
string
)
(
out
[]
string
)
{
func
appendString
(
in
[]
string
,
v
string
)
(
out
[]
string
)
{
if
cap
(
in
)
-
len
(
in
)
<
1
{
if
cap
(
in
)
-
len
(
in
)
<
1
{
out
=
make
([]
string
,
len
(
in
)
+
1
,
len
(
in
)
*
2
+
1
)
out
=
make
([]
string
,
len
(
in
)
+
1
,
len
(
in
)
*
2
+
1
)
for
i
,
v
:=
range
in
{
copy
(
out
,
in
)
out
[
i
]
=
v
}
}
else
{
}
else
{
out
=
in
[
0
:
len
(
in
)
+
1
]
out
=
in
[
0
:
len
(
in
)
+
1
]
}
}
...
...
src/pkg/debug/dwarf/type.go
View file @
d86ab015
...
@@ -454,9 +454,7 @@ func (d *Data) Type(off Offset) (Type, os.Error) {
...
@@ -454,9 +454,7 @@ func (d *Data) Type(off Offset) (Type, os.Error) {
n
:=
len
(
t
.
Field
)
n
:=
len
(
t
.
Field
)
if
n
>=
cap
(
t
.
Field
)
{
if
n
>=
cap
(
t
.
Field
)
{
fld
:=
make
([]
*
StructField
,
n
,
n
*
2
)
fld
:=
make
([]
*
StructField
,
n
,
n
*
2
)
for
i
,
f
:=
range
t
.
Field
{
copy
(
fld
,
t
.
Field
)
fld
[
i
]
=
f
}
t
.
Field
=
fld
t
.
Field
=
fld
}
}
t
.
Field
=
t
.
Field
[
0
:
n
+
1
]
t
.
Field
=
t
.
Field
[
0
:
n
+
1
]
...
@@ -505,9 +503,7 @@ func (d *Data) Type(off Offset) (Type, os.Error) {
...
@@ -505,9 +503,7 @@ func (d *Data) Type(off Offset) (Type, os.Error) {
n
:=
len
(
t
.
Val
)
n
:=
len
(
t
.
Val
)
if
n
>=
cap
(
t
.
Val
)
{
if
n
>=
cap
(
t
.
Val
)
{
val
:=
make
([]
*
EnumValue
,
n
,
n
*
2
)
val
:=
make
([]
*
EnumValue
,
n
,
n
*
2
)
for
i
,
f
:=
range
t
.
Val
{
copy
(
val
,
t
.
Val
)
val
[
i
]
=
f
}
t
.
Val
=
val
t
.
Val
=
val
}
}
t
.
Val
=
t
.
Val
[
0
:
n
+
1
]
t
.
Val
=
t
.
Val
[
0
:
n
+
1
]
...
@@ -561,9 +557,7 @@ func (d *Data) Type(off Offset) (Type, os.Error) {
...
@@ -561,9 +557,7 @@ func (d *Data) Type(off Offset) (Type, os.Error) {
n
:=
len
(
t
.
ParamType
)
n
:=
len
(
t
.
ParamType
)
if
n
>=
cap
(
t
.
ParamType
)
{
if
n
>=
cap
(
t
.
ParamType
)
{
param
:=
make
([]
Type
,
n
,
n
*
2
)
param
:=
make
([]
Type
,
n
,
n
*
2
)
for
i
,
t
:=
range
t
.
ParamType
{
copy
(
param
,
t
.
ParamType
)
param
[
i
]
=
t
}
t
.
ParamType
=
param
t
.
ParamType
=
param
}
}
t
.
ParamType
=
t
.
ParamType
[
0
:
n
+
1
]
t
.
ParamType
=
t
.
ParamType
[
0
:
n
+
1
]
...
...
src/pkg/debug/macho/file.go
View file @
d86ab015
...
@@ -306,9 +306,7 @@ func (f *File) pushSection(sh *Section, r io.ReaderAt) {
...
@@ -306,9 +306,7 @@ func (f *File) pushSection(sh *Section, r io.ReaderAt) {
if
n
>=
cap
(
f
.
Sections
)
{
if
n
>=
cap
(
f
.
Sections
)
{
m
:=
(
n
+
1
)
*
2
m
:=
(
n
+
1
)
*
2
new
:=
make
([]
*
Section
,
n
,
m
)
new
:=
make
([]
*
Section
,
n
,
m
)
for
i
,
sh
:=
range
f
.
Sections
{
copy
(
new
,
f
.
Sections
)
new
[
i
]
=
sh
}
f
.
Sections
=
new
f
.
Sections
=
new
}
}
f
.
Sections
=
f
.
Sections
[
0
:
n
+
1
]
f
.
Sections
=
f
.
Sections
[
0
:
n
+
1
]
...
...
src/pkg/exp/4s/4s.go
View file @
d86ab015
...
@@ -65,9 +65,7 @@ func audioServer() {
...
@@ -65,9 +65,7 @@ func audioServer() {
println
(
n
,
len
(
b
)
*
2
)
println
(
n
,
len
(
b
)
*
2
)
}
}
a
:=
make
([]
uint16
,
n
/
2
)
a
:=
make
([]
uint16
,
n
/
2
)
for
i
:=
range
b
{
copy
(
a
,
b
)
a
[
i
]
=
b
[
i
]
}
n
,
err
=
av
.
AudioStream
(
a
)
n
,
err
=
av
.
AudioStream
(
a
)
}
}
}
}
...
...
src/pkg/exp/eval/expr.go
View file @
d86ab015
...
@@ -1174,12 +1174,8 @@ func (a *exprInfo) compileCallExpr(b *block, l *expr, as []*expr) *expr {
...
@@ -1174,12 +1174,8 @@ func (a *exprInfo) compileCallExpr(b *block, l *expr, as []*expr) *expr {
// Gather argument and out types to initialize frame variables
// Gather argument and out types to initialize frame variables
vts
:=
make
([]
Type
,
nin
+
nout
)
vts
:=
make
([]
Type
,
nin
+
nout
)
for
i
,
t
:=
range
lt
.
In
{
copy
(
vts
,
lt
.
In
)
vts
[
i
]
=
t
copy
(
vts
[
nin
:
],
lt
.
Out
)
}
for
i
,
t
:=
range
lt
.
Out
{
vts
[
i
+
nin
]
=
t
}
// Compile
// Compile
lf
:=
l
.
asFunc
()
lf
:=
l
.
asFunc
()
...
...
src/pkg/exp/eval/func.go
View file @
d86ab015
...
@@ -46,9 +46,7 @@ func (b *codeBuf) push(instr func(*Thread)) {
...
@@ -46,9 +46,7 @@ func (b *codeBuf) push(instr func(*Thread)) {
n
:=
len
(
b
.
instrs
)
n
:=
len
(
b
.
instrs
)
if
n
>=
cap
(
b
.
instrs
)
{
if
n
>=
cap
(
b
.
instrs
)
{
a
:=
make
(
code
,
n
,
n
*
2
)
a
:=
make
(
code
,
n
,
n
*
2
)
for
i
:=
range
b
.
instrs
{
copy
(
a
,
b
.
instrs
)
a
[
i
]
=
b
.
instrs
[
i
]
}
b
.
instrs
=
a
b
.
instrs
=
a
}
}
b
.
instrs
=
b
.
instrs
[
0
:
n
+
1
]
b
.
instrs
=
b
.
instrs
[
0
:
n
+
1
]
...
@@ -60,9 +58,7 @@ func (b *codeBuf) nextPC() uint { return uint(len(b.instrs)) }
...
@@ -60,9 +58,7 @@ func (b *codeBuf) nextPC() uint { return uint(len(b.instrs)) }
func
(
b
*
codeBuf
)
get
()
code
{
func
(
b
*
codeBuf
)
get
()
code
{
// Freeze this buffer into an array of exactly the right size
// Freeze this buffer into an array of exactly the right size
a
:=
make
(
code
,
len
(
b
.
instrs
))
a
:=
make
(
code
,
len
(
b
.
instrs
))
for
i
:=
range
b
.
instrs
{
copy
(
a
,
b
.
instrs
)
a
[
i
]
=
b
.
instrs
[
i
]
}
return
code
(
a
)
return
code
(
a
)
}
}
...
...
src/pkg/exp/eval/type.go
View file @
d86ab015
...
@@ -870,9 +870,7 @@ func NewInterfaceType(methods []IMethod, embeds []*InterfaceType) *InterfaceType
...
@@ -870,9 +870,7 @@ func NewInterfaceType(methods []IMethod, embeds []*InterfaceType) *InterfaceType
// Combine methods
// Combine methods
allMethods
:=
make
([]
IMethod
,
nMethods
)
allMethods
:=
make
([]
IMethod
,
nMethods
)
for
i
,
m
:=
range
methods
{
copy
(
allMethods
,
methods
)
allMethods
[
i
]
=
m
}
n
:=
len
(
methods
)
n
:=
len
(
methods
)
for
_
,
e
:=
range
embeds
{
for
_
,
e
:=
range
embeds
{
for
_
,
m
:=
range
e
.
methods
{
for
_
,
m
:=
range
e
.
methods
{
...
...
src/pkg/exp/nacl/srpc/msg.go
View file @
d86ab015
...
@@ -126,9 +126,7 @@ func (r *msgReceiver) recv() (*msg, os.Error) {
...
@@ -126,9 +126,7 @@ func (r *msgReceiver) recv() (*msg, os.Error) {
// The system call *did* update r.hdr.ndesc.
// The system call *did* update r.hdr.ndesc.
if
r
.
hdr
.
ndesc
>
0
{
if
r
.
hdr
.
ndesc
>
0
{
m
.
rdesc
=
make
([]
int32
,
r
.
hdr
.
ndesc
)
m
.
rdesc
=
make
([]
int32
,
r
.
hdr
.
ndesc
)
for
i
:=
range
m
.
rdesc
{
copy
(
m
.
rdesc
,
r
.
desc
)
m
.
rdesc
[
i
]
=
r
.
desc
[
i
]
}
}
}
return
m
,
nil
return
m
,
nil
...
@@ -253,9 +251,7 @@ func (m *msg) wbytes(p []byte) { copy(m.grow(len(p)), p) }
...
@@ -253,9 +251,7 @@ func (m *msg) wbytes(p []byte) { copy(m.grow(len(p)), p) }
func
(
m
*
msg
)
wstring
(
s
string
)
{
func
(
m
*
msg
)
wstring
(
s
string
)
{
b
:=
m
.
grow
(
len
(
s
))
b
:=
m
.
grow
(
len
(
s
))
for
i
:=
range
b
{
copy
(
b
,
s
)
b
[
i
]
=
s
[
i
]
}
}
}
// Parsing of RPC header and arguments.
// Parsing of RPC header and arguments.
...
...
src/pkg/exp/nacl/srpc/server.go
View file @
d86ab015
...
@@ -56,9 +56,7 @@ func Add(name, fmt string, handler Handler) {
...
@@ -56,9 +56,7 @@ func Add(name, fmt string, handler Handler) {
n
:=
len
(
rpcMethod
)
n
:=
len
(
rpcMethod
)
if
n
>=
cap
(
rpcMethod
)
{
if
n
>=
cap
(
rpcMethod
)
{
a
:=
make
([]
method
,
n
,
(
n
+
4
)
*
2
)
a
:=
make
([]
method
,
n
,
(
n
+
4
)
*
2
)
for
i
:=
range
a
{
copy
(
a
,
rpcMethod
)
a
[
i
]
=
rpcMethod
[
i
]
}
rpcMethod
=
a
rpcMethod
=
a
}
}
rpcMethod
=
rpcMethod
[
0
:
n
+
1
]
rpcMethod
=
rpcMethod
[
0
:
n
+
1
]
...
...
src/pkg/exp/ogle/process.go
View file @
d86ab015
...
@@ -396,9 +396,7 @@ func (p *Process) postEvent(ev Event) {
...
@@ -396,9 +396,7 @@ func (p *Process) postEvent(ev Event) {
m
=
4
m
=
4
}
}
posted
:=
make
([]
Event
,
n
+
1
,
m
)
posted
:=
make
([]
Event
,
n
+
1
,
m
)
for
i
,
p
:=
range
p
.
posted
{
copy
(
posted
,
p
.
posted
)
posted
[
i
]
=
p
}
posted
[
n
]
=
ev
posted
[
n
]
=
ev
p
.
posted
=
posted
p
.
posted
=
posted
}
}
...
...
src/pkg/go/doc/doc.go
View file @
d86ab015
...
@@ -277,11 +277,9 @@ func (doc *docReader) addDecl(decl ast.Decl) {
...
@@ -277,11 +277,9 @@ func (doc *docReader) addDecl(decl ast.Decl) {
func
copyCommentList
(
list
[]
*
ast
.
Comment
)
[]
*
ast
.
Comment
{
func
copyCommentList
(
list
[]
*
ast
.
Comment
)
[]
*
ast
.
Comment
{
copy
:=
make
([]
*
ast
.
Comment
,
len
(
list
))
nlist
:=
make
([]
*
ast
.
Comment
,
len
(
list
))
for
i
,
c
:=
range
list
{
copy
(
nlist
,
list
)
copy
[
i
]
=
c
return
nlist
}
return
copy
}
}
...
...
src/pkg/net/dnsmsg.go
View file @
d86ab015
...
@@ -430,10 +430,7 @@ func packStructValue(val *reflect.StructValue, msg []byte, off int) (off1 int, o
...
@@ -430,10 +430,7 @@ func packStructValue(val *reflect.StructValue, msg []byte, off int) (off1 int, o
}
}
msg
[
off
]
=
byte
(
len
(
s
))
msg
[
off
]
=
byte
(
len
(
s
))
off
++
off
++
for
i
:=
0
;
i
<
len
(
s
);
i
++
{
off
+=
copy
(
msg
[
off
:
],
s
)
msg
[
off
+
i
]
=
s
[
i
]
}
off
+=
len
(
s
)
}
}
}
}
}
}
...
...
src/pkg/os/dir_darwin.go
View file @
d86ab015
...
@@ -66,9 +66,7 @@ func (file *File) Readdirnames(count int) (names []string, err Error) {
...
@@ -66,9 +66,7 @@ func (file *File) Readdirnames(count int) (names []string, err Error) {
count
--
count
--
if
len
(
names
)
==
cap
(
names
)
{
if
len
(
names
)
==
cap
(
names
)
{
nnames
:=
make
([]
string
,
len
(
names
),
2
*
len
(
names
))
nnames
:=
make
([]
string
,
len
(
names
),
2
*
len
(
names
))
for
i
:=
0
;
i
<
len
(
names
);
i
++
{
copy
(
nnames
,
names
)
nnames
[
i
]
=
names
[
i
]
}
names
=
nnames
names
=
nnames
}
}
names
=
names
[
0
:
len
(
names
)
+
1
]
names
=
names
[
0
:
len
(
names
)
+
1
]
...
...
src/pkg/os/dir_freebsd.go
View file @
d86ab015
...
@@ -61,9 +61,7 @@ func (file *File) Readdirnames(count int) (names []string, err Error) {
...
@@ -61,9 +61,7 @@ func (file *File) Readdirnames(count int) (names []string, err Error) {
count
--
count
--
if
len
(
names
)
==
cap
(
names
)
{
if
len
(
names
)
==
cap
(
names
)
{
nnames
:=
make
([]
string
,
len
(
names
),
2
*
len
(
names
))
nnames
:=
make
([]
string
,
len
(
names
),
2
*
len
(
names
))
for
i
:=
0
;
i
<
len
(
names
);
i
++
{
copy
(
nnames
,
names
)
nnames
[
i
]
=
names
[
i
]
}
names
=
nnames
names
=
nnames
}
}
names
=
names
[
0
:
len
(
names
)
+
1
]
names
=
names
[
0
:
len
(
names
)
+
1
]
...
...
src/pkg/os/dir_linux.go
View file @
d86ab015
...
@@ -64,9 +64,7 @@ func (file *File) Readdirnames(count int) (names []string, err Error) {
...
@@ -64,9 +64,7 @@ func (file *File) Readdirnames(count int) (names []string, err Error) {
count
--
count
--
if
len
(
names
)
==
cap
(
names
)
{
if
len
(
names
)
==
cap
(
names
)
{
nnames
:=
make
([]
string
,
len
(
names
),
2
*
len
(
names
))
nnames
:=
make
([]
string
,
len
(
names
),
2
*
len
(
names
))
for
i
:=
0
;
i
<
len
(
names
);
i
++
{
copy
(
nnames
,
names
)
nnames
[
i
]
=
names
[
i
]
}
names
=
nnames
names
=
nnames
}
}
names
=
names
[
0
:
len
(
names
)
+
1
]
names
=
names
[
0
:
len
(
names
)
+
1
]
...
...
src/pkg/os/dir_nacl.go
View file @
d86ab015
...
@@ -64,9 +64,7 @@ func (file *File) Readdirnames(count int) (names []string, err Error) {
...
@@ -64,9 +64,7 @@ func (file *File) Readdirnames(count int) (names []string, err Error) {
count
--
count
--
if
len
(
names
)
==
cap
(
names
)
{
if
len
(
names
)
==
cap
(
names
)
{
nnames
:=
make
([]
string
,
len
(
names
),
2
*
len
(
names
))
nnames
:=
make
([]
string
,
len
(
names
),
2
*
len
(
names
))
for
i
:=
0
;
i
<
len
(
names
);
i
++
{
copy
(
nnames
,
names
)
nnames
[
i
]
=
names
[
i
]
}
names
=
nnames
names
=
nnames
}
}
names
=
names
[
0
:
len
(
names
)
+
1
]
names
=
names
[
0
:
len
(
names
)
+
1
]
...
...
src/pkg/os/env_windows.go
View file @
d86ab015
...
@@ -89,9 +89,7 @@ func Environ() []string {
...
@@ -89,9 +89,7 @@ func Environ() []string {
}
}
if
len
(
r
)
==
cap
(
r
)
{
if
len
(
r
)
==
cap
(
r
)
{
nr
:=
make
([]
string
,
len
(
r
),
2
*
len
(
r
))
nr
:=
make
([]
string
,
len
(
r
),
2
*
len
(
r
))
for
k
:=
0
;
k
<
len
(
r
);
k
++
{
copy
(
nr
,
r
)
nr
[
k
]
=
r
[
k
]
}
r
=
nr
r
=
nr
}
}
r
=
r
[
0
:
len
(
r
)
+
1
]
r
=
r
[
0
:
len
(
r
)
+
1
]
...
...
src/pkg/os/file_windows.go
View file @
d86ab015
...
@@ -159,9 +159,7 @@ func (file *File) Readdir(count int) (fi []FileInfo, err Error) {
...
@@ -159,9 +159,7 @@ func (file *File) Readdir(count int) (fi []FileInfo, err Error) {
count
--
count
--
if
len
(
fi
)
==
cap
(
fi
)
{
if
len
(
fi
)
==
cap
(
fi
)
{
nfi
:=
make
([]
FileInfo
,
len
(
fi
),
2
*
len
(
fi
))
nfi
:=
make
([]
FileInfo
,
len
(
fi
),
2
*
len
(
fi
))
for
i
:=
0
;
i
<
len
(
fi
);
i
++
{
copy
(
nfi
,
fi
)
nfi
[
i
]
=
fi
[
i
]
}
fi
=
nfi
fi
=
nfi
}
}
fi
=
fi
[
0
:
len
(
fi
)
+
1
]
fi
=
fi
[
0
:
len
(
fi
)
+
1
]
...
...
src/pkg/scanner/scanner_test.go
View file @
d86ab015
...
@@ -23,10 +23,7 @@ type StringReader struct {
...
@@ -23,10 +23,7 @@ type StringReader struct {
func
(
r
*
StringReader
)
Read
(
p
[]
byte
)
(
n
int
,
err
os
.
Error
)
{
func
(
r
*
StringReader
)
Read
(
p
[]
byte
)
(
n
int
,
err
os
.
Error
)
{
if
r
.
step
<
len
(
r
.
data
)
{
if
r
.
step
<
len
(
r
.
data
)
{
s
:=
r
.
data
[
r
.
step
]
s
:=
r
.
data
[
r
.
step
]
for
i
:=
0
;
i
<
len
(
s
);
i
++
{
n
=
copy
(
p
,
s
)
p
[
i
]
=
s
[
i
]
}
n
=
len
(
s
)
r
.
step
++
r
.
step
++
}
else
{
}
else
{
err
=
os
.
EOF
err
=
os
.
EOF
...
...
src/pkg/strings/strings.go
View file @
d86ab015
...
@@ -527,21 +527,10 @@ func Replace(s, old, new string, n int) string {
...
@@ -527,21 +527,10 @@ func Replace(s, old, new string, n int) string {
}
else
{
}
else
{
j
+=
Index
(
s
[
start
:
],
old
)
j
+=
Index
(
s
[
start
:
],
old
)
}
}
w
+=
copy
String
(
t
[
w
:
],
s
[
start
:
j
])
w
+=
copy
(
t
[
w
:
],
s
[
start
:
j
])
w
+=
copy
String
(
t
[
w
:
],
new
)
w
+=
copy
(
t
[
w
:
],
new
)
start
=
j
+
len
(
old
)
start
=
j
+
len
(
old
)
}
}
w
+=
copy
String
(
t
[
w
:
],
s
[
start
:
])
w
+=
copy
(
t
[
w
:
],
s
[
start
:
])
return
string
(
t
[
0
:
w
])
return
string
(
t
[
0
:
w
])
}
}
func
copyString
(
dst
[]
byte
,
src
string
)
int
{
n
:=
len
(
dst
)
if
n
>
len
(
src
)
{
n
=
len
(
src
)
}
for
i
:=
0
;
i
<
n
;
i
++
{
dst
[
i
]
=
src
[
i
]
}
return
n
}
src/pkg/syscall/syscall.go
View file @
d86ab015
...
@@ -21,9 +21,7 @@ func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
...
@@ -21,9 +21,7 @@ func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
// containing the text of s.
// containing the text of s.
func
StringByteSlice
(
s
string
)
[]
byte
{
func
StringByteSlice
(
s
string
)
[]
byte
{
a
:=
make
([]
byte
,
len
(
s
)
+
1
)
a
:=
make
([]
byte
,
len
(
s
)
+
1
)
for
i
:=
0
;
i
<
len
(
s
);
i
++
{
copy
(
a
,
s
)
a
[
i
]
=
s
[
i
]
}
return
a
return
a
}
}
...
...
src/pkg/template/template.go
View file @
d86ab015
...
@@ -320,9 +320,7 @@ func words(buf []byte) []string {
...
@@ -320,9 +320,7 @@ func words(buf []byte) []string {
}
}
if
i
==
cap
(
s
)
{
if
i
==
cap
(
s
)
{
ns
:=
make
([]
string
,
2
*
cap
(
s
))
ns
:=
make
([]
string
,
2
*
cap
(
s
))
for
j
:=
range
s
{
copy
(
ns
,
s
)
ns
[
j
]
=
s
[
j
]
}
s
=
ns
s
=
ns
}
}
s
=
s
[
0
:
i
+
1
]
s
=
s
[
0
:
i
+
1
]
...
...
src/pkg/testing/regexp.go
View file @
d86ab015
...
@@ -170,9 +170,7 @@ func (cclass *_CharClass) addRange(a, b int) {
...
@@ -170,9 +170,7 @@ func (cclass *_CharClass) addRange(a, b int) {
n
:=
len
(
cclass
.
ranges
)
n
:=
len
(
cclass
.
ranges
)
if
n
>=
cap
(
cclass
.
ranges
)
{
if
n
>=
cap
(
cclass
.
ranges
)
{
nr
:=
make
([]
int
,
n
,
2
*
n
)
nr
:=
make
([]
int
,
n
,
2
*
n
)
for
i
,
j
:=
range
nr
{
copy
(
nr
,
cclass
.
ranges
)
nr
[
i
]
=
j
}
cclass
.
ranges
=
nr
cclass
.
ranges
=
nr
}
}
cclass
.
ranges
=
cclass
.
ranges
[
0
:
n
+
2
]
cclass
.
ranges
=
cclass
.
ranges
[
0
:
n
+
2
]
...
@@ -255,9 +253,7 @@ func (re *Regexp) add(i instr) instr {
...
@@ -255,9 +253,7 @@ func (re *Regexp) add(i instr) instr {
i
.
setIndex
(
len
(
re
.
inst
))
i
.
setIndex
(
len
(
re
.
inst
))
if
n
>=
cap
(
re
.
inst
)
{
if
n
>=
cap
(
re
.
inst
)
{
ni
:=
make
([]
instr
,
n
,
2
*
n
)
ni
:=
make
([]
instr
,
n
,
2
*
n
)
for
i
,
j
:=
range
re
.
inst
{
copy
(
ni
,
re
.
inst
)
ni
[
i
]
=
j
}
re
.
inst
=
ni
re
.
inst
=
ni
}
}
re
.
inst
=
re
.
inst
[
0
:
n
+
1
]
re
.
inst
=
re
.
inst
[
0
:
n
+
1
]
...
...
src/pkg/unicode/maketables.go
View file @
d86ab015
...
@@ -496,9 +496,7 @@ func parseScript(line string, scripts map[string][]Script) {
...
@@ -496,9 +496,7 @@ func parseScript(line string, scripts map[string][]Script) {
s
,
ok
:=
scripts
[
name
]
s
,
ok
:=
scripts
[
name
]
if
!
ok
||
len
(
s
)
==
cap
(
s
)
{
if
!
ok
||
len
(
s
)
==
cap
(
s
)
{
ns
:=
make
([]
Script
,
len
(
s
),
len
(
s
)
+
100
)
ns
:=
make
([]
Script
,
len
(
s
),
len
(
s
)
+
100
)
for
i
,
sc
:=
range
s
{
copy
(
ns
,
s
)
ns
[
i
]
=
sc
}
s
=
ns
s
=
ns
}
}
s
=
s
[
0
:
len
(
s
)
+
1
]
s
=
s
[
0
:
len
(
s
)
+
1
]
...
...
src/pkg/xml/xml.go
View file @
d86ab015
...
@@ -595,9 +595,7 @@ func (p *Parser) RawToken() (Token, os.Error) {
...
@@ -595,9 +595,7 @@ func (p *Parser) RawToken() (Token, os.Error) {
n
:=
len
(
attr
)
n
:=
len
(
attr
)
if
n
>=
cap
(
attr
)
{
if
n
>=
cap
(
attr
)
{
nattr
:=
make
([]
Attr
,
n
,
2
*
cap
(
attr
))
nattr
:=
make
([]
Attr
,
n
,
2
*
cap
(
attr
))
for
i
,
a
:=
range
attr
{
copy
(
nattr
,
attr
)
nattr
[
i
]
=
a
}
attr
=
nattr
attr
=
nattr
}
}
attr
=
attr
[
0
:
n
+
1
]
attr
=
attr
[
0
:
n
+
1
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment