Commit 79b5c2e4 authored by Kevin Atkinson's avatar Kevin Atkinson

ds-help: avoid unnecessary allocs when posssible and make use of RawKey

License: MIT
Signed-off-by: default avatarKevin Atkinson <k@kevina.org>
parent 7c7f24a9
......@@ -40,13 +40,13 @@ func (c *client) PutValue(ctx context.Context, key string, val []byte) error {
return err
}
return c.datastore.Put(dshelp.NewKeyFromBinary(key), data)
return c.datastore.Put(dshelp.NewKeyFromBinary([]byte(key)), data)
}
// FIXME(brian): is this method meant to simulate getting a value from the network?
func (c *client) GetValue(ctx context.Context, key string) ([]byte, error) {
log.Debugf("GetValue: %s", key)
v, err := c.datastore.Get(dshelp.NewKeyFromBinary(key))
v, err := c.datastore.Get(dshelp.NewKeyFromBinary([]byte(key)))
if err != nil {
return nil, err
}
......
......@@ -48,11 +48,11 @@ func (c *offlineRouting) PutValue(ctx context.Context, key string, val []byte) e
return err
}
return c.datastore.Put(dshelp.NewKeyFromBinary(key), data)
return c.datastore.Put(dshelp.NewKeyFromBinary([]byte(key)), data)
}
func (c *offlineRouting) GetValue(ctx context.Context, key string) ([]byte, error) {
v, err := c.datastore.Get(dshelp.NewKeyFromBinary(key))
v, err := c.datastore.Get(dshelp.NewKeyFromBinary([]byte(key)))
if err != nil {
return nil, err
}
......@@ -71,7 +71,7 @@ func (c *offlineRouting) GetValue(ctx context.Context, key string) ([]byte, erro
}
func (c *offlineRouting) GetValues(ctx context.Context, key string, _ int) ([]routing.RecvdVal, error) {
v, err := c.datastore.Get(dshelp.NewKeyFromBinary(key))
v, err := c.datastore.Get(dshelp.NewKeyFromBinary([]byte(key)))
if err != nil {
return nil, err
}
......
......@@ -117,7 +117,7 @@ var _ proxy.RequestHandler = &Server{}
var _ proxy.Proxy = &Server{}
func getRoutingRecord(ds datastore.Datastore, k string) (*pb.Record, error) {
dskey := dshelp.NewKeyFromBinary(k)
dskey := dshelp.NewKeyFromBinary([]byte(k))
val, err := ds.Get(dskey)
if err != nil {
return nil, err
......@@ -138,7 +138,7 @@ func putRoutingRecord(ds datastore.Datastore, k string, value *pb.Record) error
if err != nil {
return err
}
dskey := dshelp.NewKeyFromBinary(k)
dskey := dshelp.NewKeyFromBinary([]byte(k))
// TODO namespace
if err := ds.Put(dskey, data); err != nil {
return err
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment