diff options
Diffstat (limited to 'src/pkg/bytes/buffer.go')
-rw-r--r-- | src/pkg/bytes/buffer.go | 7 |
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 |