mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
Remove copyBytes completely in favor of copy.
R=r, rsc https://golang.org/cl/165068
This commit is contained in:
parent
20c1ec263a
commit
8c22dd24e0
1 changed files with 2 additions and 11 deletions
|
|
@ -19,15 +19,6 @@ func copyString(dst []byte, doff int, str string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy from bytes to byte array at offset doff. Assume there's room.
|
|
||||||
func copyBytes(dst []byte, doff int, src []byte) {
|
|
||||||
if len(src) == 1 {
|
|
||||||
dst[doff] = src[0];
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
copy(dst[doff:], src);
|
|
||||||
}
|
|
||||||
|
|
||||||
// A Buffer is a variable-sized buffer of bytes
|
// A Buffer is a variable-sized buffer of bytes
|
||||||
// with Read and Write methods.
|
// 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.
|
||||||
|
|
@ -98,7 +89,7 @@ func (b *Buffer) Write(p []byte) (n int, err os.Error) {
|
||||||
b.resize(n)
|
b.resize(n)
|
||||||
}
|
}
|
||||||
b.buf = b.buf[0 : b.off+m+n];
|
b.buf = b.buf[0 : b.off+m+n];
|
||||||
copyBytes(b.buf, b.off+m, p);
|
copy(b.buf[b.off+m:], p);
|
||||||
return n, nil;
|
return n, nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -194,7 +185,7 @@ func (b *Buffer) Read(p []byte) (n int, err os.Error) {
|
||||||
n = m
|
n = m
|
||||||
}
|
}
|
||||||
|
|
||||||
copyBytes(p, 0, b.buf[b.off:b.off+n]);
|
copy(p, b.buf[b.off:b.off+n]);
|
||||||
b.off += n;
|
b.off += n;
|
||||||
return n, err;
|
return n, err;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue