Skip to content

Commit a999acd

Browse files
committed
Buffer.Clone() should avoid bit-shifting.
1 parent acd4a05 commit a999acd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

buffer.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ func (buf *Buffer) Clone() *Buffer {
9292
if buf.Len() == 0 {
9393
return &Buffer{}
9494
}
95-
b := allocByteSlice((buf.nBits + 7) >> 3)
96-
copyBits(b, buf.b, 0, buf.off, buf.nBits)
95+
b := make([]byte, len(buf.b))
96+
copy(b, buf.b)
9797

98-
return &Buffer{b: b, nBits: buf.nBits}
98+
return &Buffer{b: b, nBits: buf.nBits, off: buf.off}
9999
}
100100

101101
// BitArray creates an imuurable BitArray from the current content.

0 commit comments

Comments
 (0)