bytepool: enforce equal length and cap
This commit is contained in:
parent
c4706022d7
commit
57ee2d0c90
2 changed files with 4 additions and 4 deletions
|
@ -7,11 +7,11 @@ type BytePool struct {
|
|||
sync.Pool
|
||||
}
|
||||
|
||||
// New allocates a new BytePool with slices of the provided capacity.
|
||||
func New(length, capacity int) *BytePool {
|
||||
// New allocates a new BytePool with slices of equal length and capacity.
|
||||
func New(length int) *BytePool {
|
||||
var bp BytePool
|
||||
bp.Pool.New = func() interface{} {
|
||||
return make([]byte, length, capacity)
|
||||
return make([]byte, length, length)
|
||||
}
|
||||
return &bp
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ func (t *Frontend) ListenAndServe() error {
|
|||
}
|
||||
defer t.socket.Close()
|
||||
|
||||
pool := bytepool.New(2048, 2048)
|
||||
pool := bytepool.New(2048)
|
||||
|
||||
for {
|
||||
// Check to see if we need to shutdown.
|
||||
|
|
Loading…
Reference in a new issue