change uint32 to int32

This commit is contained in:
Darien Raymond
2018-04-02 22:01:55 +02:00
parent 81a147e540
commit c5bd23105e
7 changed files with 16 additions and 16 deletions
+6 -6
View File
@@ -9,7 +9,7 @@ const (
Size = 2 * 1024
)
func createAllocFunc(size uint32) func() interface{} {
func createAllocFunc(size int32) func() interface{} {
return func() interface{} {
return make([]byte, size)
}
@@ -26,12 +26,12 @@ const (
var (
pool [numPools]sync.Pool
poolSize [numPools]uint32
largeSize uint32
poolSize [numPools]int32
largeSize int32
)
func init() {
size := uint32(Size)
size := int32(Size)
for i := 0; i < numPools; i++ {
pool[i] = sync.Pool{
New: createAllocFunc(size),
@@ -42,7 +42,7 @@ func init() {
}
}
func newBytes(size uint32) []byte {
func newBytes(size int32) []byte {
for idx, ps := range poolSize {
if size <= ps {
return pool[idx].Get().([]byte)
@@ -52,7 +52,7 @@ func newBytes(size uint32) []byte {
}
func freeBytes(b []byte) {
size := uint32(cap(b))
size := int32(cap(b))
b = b[0:cap(b)]
for i := numPools - 1; i >= 0; i-- {
if size >= poolSize[i] {