mirror of
https://github.com/sot-tech/mochi.git
synced 2026-06-11 15:33:31 -07:00
bytepool: enforce equal length and cap
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user