use idToKeyBuf in diff and delta cache

master
Oliver Tonnhofer 2013-05-10 11:11:29 +02:00
parent 27de965bd5
commit 69ee95fa27
2 changed files with 4 additions and 10 deletions

7
cache/delta.go vendored
View File

@ -3,7 +3,6 @@ package cache
import (
"code.google.com/p/goprotobuf/proto"
"container/list"
bin "encoding/binary"
"goposm/binary"
"goposm/element"
"sort"
@ -177,8 +176,7 @@ func (p *DeltaCoordsCache) putCoordsPacked(bunchId int64, nodes []element.Node)
if len(nodes) == 0 {
return
}
keyBuf := make([]byte, 8)
bin.PutVarint(keyBuf, bunchId)
keyBuf := idToKeyBuf(bunchId)
deltaCoords := packNodes(nodes)
data, err := proto.Marshal(deltaCoords)
@ -189,8 +187,7 @@ func (p *DeltaCoordsCache) putCoordsPacked(bunchId int64, nodes []element.Node)
}
func (p *DeltaCoordsCache) getCoordsPacked(bunchId int64, nodes []element.Node) []element.Node {
keyBuf := make([]byte, 8)
bin.PutVarint(keyBuf, bunchId)
keyBuf := idToKeyBuf(bunchId)
data, err := p.db.Get(p.ro, keyBuf)
if err != nil {

7
cache/diff.go vendored
View File

@ -2,7 +2,6 @@ package cache
import (
"code.google.com/p/goprotobuf/proto"
bin "encoding/binary"
"os"
"path/filepath"
"sort"
@ -89,8 +88,7 @@ func NewRefIndex(path string) (*RefIndex, error) {
}
func (index *RefIndex) Add(id, ref int64) error {
keyBuf := make([]byte, 8)
bin.PutVarint(keyBuf, id)
keyBuf := idToKeyBuf(id)
data, err := index.db.Get(index.ro, keyBuf)
if err != nil {
panic(err)
@ -131,8 +129,7 @@ func (r *Refs) insertId(ref int64) {
}
func (index *RefIndex) Get(id int64) []int64 {
keyBuf := make([]byte, 8)
bin.PutVarint(keyBuf, id)
keyBuf := idToKeyBuf(id)
data, err := index.db.Get(index.ro, keyBuf)
refs := &Refs{}
if data != nil {