diff --git a/archiver.go b/archiver.go index ae49248ff..a5ead7f9c 100644 --- a/archiver.go +++ b/archiver.go @@ -108,7 +108,6 @@ func (arch *Archiver) Save(t backend.Type, id backend.ID, length uint, rd io.Rea blob, err := arch.m.FindID(id) if err == nil { debug.Log("Archiver.Save", "Save(%v, %v): reusing %v\n", t, id.Str(), blob.Storage.Str()) - id.Free() return blob, nil } diff --git a/backend/generic.go b/backend/generic.go index 42d4258de..173f4e1b1 100644 --- a/backend/generic.go +++ b/backend/generic.go @@ -23,7 +23,7 @@ const hashSize = sha256.Size // Hash returns the ID for data. func Hash(data []byte) ID { h := hashData(data) - id := idPool.Get().(ID) + id := make([]byte, IDSize) copy(id, h[:]) return id } diff --git a/backend/id.go b/backend/id.go index dccf18ccd..261f4802d 100644 --- a/backend/id.go +++ b/backend/id.go @@ -5,7 +5,6 @@ import ( "encoding/hex" "encoding/json" "errors" - "sync" ) // IDSize contains the size of an ID, in bytes. @@ -14,8 +13,6 @@ const IDSize = hashSize // References content within a repository. type ID []byte -var idPool = sync.Pool{New: func() interface{} { return ID(make([]byte, IDSize)) }} - // ParseID converts the given string to an ID. func ParseID(s string) (ID, error) { b, err := hex.DecodeString(s) @@ -75,7 +72,7 @@ func (id *ID) UnmarshalJSON(b []byte) error { return err } - *id = idPool.Get().(ID) + *id = make([]byte, IDSize) _, err = hex.Decode(*id, []byte(s)) if err != nil { return err @@ -86,16 +83,11 @@ func (id *ID) UnmarshalJSON(b []byte) error { func IDFromData(d []byte) ID { hash := hashData(d) - id := idPool.Get().(ID) + id := make([]byte, IDSize) copy(id, hash[:]) return id } -// Free returns the ID byte slice back to the allocation pool. -func (id ID) Free() { - idPool.Put(id) -} - type IDs []ID func (ids IDs) Len() int { diff --git a/blob.go b/blob.go index acbe7d214..1619b7db9 100644 --- a/blob.go +++ b/blob.go @@ -16,16 +16,6 @@ type Blob struct { type Blobs []Blob -func (b Blob) Free() { - if b.ID != nil { - b.ID.Free() - } - - if b.Storage != nil { - b.Storage.Free() - } -} - func (b Blob) Valid() bool { if b.ID == nil || b.Storage == nil || b.StorageSize == 0 { return false diff --git a/node.go b/node.go index b49554835..0729493d0 100644 --- a/node.go +++ b/node.go @@ -58,11 +58,12 @@ func (node Node) Tree() *Tree { } func NodeFromFileInfo(path string, fi os.FileInfo) (*Node, error) { - node := GetNode() - node.path = path - node.Name = fi.Name() - node.Mode = fi.Mode() & os.ModePerm - node.ModTime = fi.ModTime() + node := &Node{ + path: path, + Name: fi.Name(), + Mode: fi.Mode() & os.ModePerm, + ModTime: fi.ModTime(), + } node.Type = nodeTypeFromFileInfo(path, fi) if node.Type == "file" { diff --git a/pools.go b/pools.go index cf8e899a9..a99f631ec 100644 --- a/pools.go +++ b/pools.go @@ -67,7 +67,6 @@ func newPoolStats() *poolStats { var ( chunkPool = sync.Pool{New: newChunkBuf} - nodePool = sync.Pool{New: newNode} chunkerPool = sync.Pool{New: newChunker} chunkStats = newPoolStats() @@ -84,15 +83,6 @@ func newChunkBuf() interface{} { return make([]byte, maxCiphertextSize) } -func newNode() interface{} { - nodeStats.m.Lock() - defer nodeStats.m.Unlock() - nodeStats.new++ - - // create buffer for iv, data and hmac - return new(Node) -} - func newChunker() interface{} { chunkStats.m.Lock() defer chunkStats.m.Unlock() @@ -112,16 +102,6 @@ func FreeChunkBuf(s string, buf []byte) { chunkPool.Put(buf) } -func GetNode() *Node { - nodeStats.Get("") - return nodePool.Get().(*Node) -} - -func FreeNode(n *Node) { - nodeStats.Put("") - nodePool.Put(n) -} - func GetChunker(s string) *chunker.Chunker { chunkerStats.Get(s) return chunkerPool.Get().(*chunker.Chunker)