summaryrefslogtreecommitdiff
path: root/src/pkg/bytes/buffer.go
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2009-11-18 15:24:24 -0800
committerRob Pike <r@golang.org>2009-11-18 15:24:24 -0800
commit391051631f6118f60751735160d4f5a4b41ba5db (patch)
treea54bad89b8447ed713d40539471ce8d1b9f811ff /src/pkg/bytes/buffer.go
parente97248aec165fe74b5b765813d8d8f9e44790910 (diff)
downloadgolang-391051631f6118f60751735160d4f5a4b41ba5db.tar.gz
remove bytes.Copy
replace all calls with calls to copy use copy in regexp and bytes.Buffer R=rsc CC=golang-dev http://codereview.appspot.com/157073
Diffstat (limited to 'src/pkg/bytes/buffer.go')
-rw-r--r--src/pkg/bytes/buffer.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/pkg/bytes/buffer.go b/src/pkg/bytes/buffer.go
index 76d67e777..0bbc06c32 100644
--- a/src/pkg/bytes/buffer.go
+++ b/src/pkg/bytes/buffer.go
@@ -20,10 +20,11 @@ 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) {
- for soff := 0; soff < len(src); soff++ {
- dst[doff] = src[soff];
- doff++;
+ if len(src) == 1 {
+ dst[doff] = src[0];
+ return;
}
+ copy(dst[doff:len(dst)], src);
}
// A Buffer is a variable-sized buffer of bytes