Skip to content

Commit f35084e

Browse files
committed
core/byt: m rename var
1 parent ce343fc commit f35084e

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

intra/core/byt.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ func (w *ByteWriter) Write(p []byte) (n int, err error) {
2323
bptr = AllocRegion(len(p))
2424
w.b = bptr
2525
}
26+
// TODO: copy when cap(*bptr) < len(*bptr)+len(p)?
2627
// append may grow the slice beyond original capacity
2728
// and so, it may get recycled to a higher slab on Close
2829
*bptr = append(*bptr, p...)
@@ -48,32 +49,32 @@ func (w *ByteWriter) Bytes() []byte {
4849
}
4950

5051
func (w *ByteWriter) Copy() []byte {
51-
if bptr := w.b; bptr != nil {
52-
bcopy := make([]byte, len(*bptr))
53-
copy(bcopy, *bptr)
54-
return bcopy
52+
if b := w.b; b != nil {
53+
c := make([]byte, len(*b))
54+
copy(c, *b)
55+
return c
5556
}
5657
return nil
5758
}
5859

5960
func (w *ByteWriter) Dup() ByteWriter {
60-
if bptr := w.b; bptr != nil {
61-
bptr2 := AllocRegion(len(*bptr))
62-
copy(*bptr2, *bptr)
63-
return ByteWriter{b: bptr2}
61+
if b := w.b; b != nil {
62+
b2 := AllocRegion(len(*b))
63+
copy(*b2, *b)
64+
return ByteWriter{b: b2}
6465
}
6566
return ByteWriter{}
6667
}
6768

6869
func (w *ByteWriter) Len() int {
69-
if bptr := w.b; bptr != nil {
70-
return len(*bptr)
70+
if b := w.b; b != nil {
71+
return len(*b)
7172
}
7273
return 0
7374
}
7475

7576
func (w *ByteWriter) Reset() {
76-
if bptr := w.b; bptr != nil {
77-
*bptr = (*bptr)[:0]
77+
if b := w.b; b != nil {
78+
*b = (*b)[:0]
7879
}
7980
}

0 commit comments

Comments
 (0)