Browse Source

simpify Buffer.FillFrom()

Darien Raymond 9 năm trước cách đây
mục cha
commit
10b75e8961
1 tập tin đã thay đổi với 2 bổ sung3 xóa
  1. 2 3
      common/alloc/buffer.go

+ 2 - 3
common/alloc/buffer.go

@@ -219,9 +219,8 @@ func (b *Buffer) Read(data []byte) (int, error) {
 
 func (b *Buffer) FillFrom(reader io.Reader) (int, error) {
 	begin := b.Len()
-	b.Value = b.Value[:cap(b.Value)]
-	nBytes, err := reader.Read(b.Value[begin:])
-	b.Value = b.Value[:begin+nBytes]
+	nBytes, err := reader.Read(b.head[b.offset+begin:])
+	b.Value = b.head[:b.offset+begin+nBytes]
 	return nBytes, err
 }