mirror of https://github.com/ledisdb/ledisdb.git
update godep
This commit is contained in:
parent
6b7ab2b02d
commit
4d6d402520
|
@ -22,10 +22,6 @@
|
|||
"ImportPath": "github.com/edsrzf/mmap-go",
|
||||
"Rev": "6c75090c55983bef2e129e173681b20d24871ef8"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/siddontang/go/arena",
|
||||
"Rev": "c2b33271306fcb7c6532efceac33ec45ee2439e0"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/siddontang/go/bson",
|
||||
"Rev": "c2b33271306fcb7c6532efceac33ec45ee2439e0"
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
package arena
|
||||
|
||||
type Arena struct {
|
||||
buf []byte
|
||||
|
||||
offset int
|
||||
}
|
||||
|
||||
func NewArena(size int) *Arena {
|
||||
a := new(Arena)
|
||||
|
||||
a.buf = make([]byte, size, size)
|
||||
a.offset = 0
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *Arena) Make(size int) []byte {
|
||||
if len(a.buf) < size || len(a.buf)-a.offset < size {
|
||||
return make([]byte, size)
|
||||
}
|
||||
|
||||
b := a.buf[a.offset : size+a.offset]
|
||||
a.offset += size
|
||||
return b
|
||||
}
|
||||
|
||||
func (a *Arena) Reset() {
|
||||
a.offset = 0
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
package arena
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestArena(t *testing.T) {
|
||||
a := NewArena(100)
|
||||
|
||||
for i := 0; i < 50; i++ {
|
||||
a.buf[i] = 1
|
||||
}
|
||||
|
||||
for i := 50; i < 100; i++ {
|
||||
a.buf[i] = 2
|
||||
}
|
||||
|
||||
b1 := a.Make(50)
|
||||
|
||||
b2 := a.Make(30)
|
||||
|
||||
b3 := a.Make(40)
|
||||
|
||||
fmt.Printf("%p %d\n", b1, b1[49])
|
||||
fmt.Printf("%p %d\n", b2, b2[29])
|
||||
fmt.Printf("%p %d\n", b3, b3[39])
|
||||
}
|
Loading…
Reference in New Issue