Skip to content

Commit fba0ad9

Browse files
committed
buffer: optimize default branches
1 parent d09ac83 commit fba0ad9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

buffer.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,18 +130,18 @@ func (b *buffer) takeBuffer(length int) []byte {
130130
// smaller than defaultBufSize
131131
// Only one buffer (total) can be used at a time.
132132
func (b *buffer) takeSmallBuffer(length int) []byte {
133-
if b.length == 0 {
134-
return b.buf[:length]
133+
if b.length > 0 {
134+
return nil
135135
}
136-
return nil
136+
return b.buf[:length]
137137
}
138138

139139
// takeCompleteBuffer returns the complete existing buffer.
140140
// This can be used if the necessary buffer size is unknown.
141141
// Only one buffer (total) can be used at a time.
142142
func (b *buffer) takeCompleteBuffer() []byte {
143-
if b.length == 0 {
144-
return b.buf
143+
if b.length > 0 {
144+
return nil
145145
}
146-
return nil
146+
return b.buf
147147
}

0 commit comments

Comments
 (0)