From b9c8eca468259c087931a6c98129fd38892f834c Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 15 Feb 2022 12:56:23 +0100 Subject: [PATCH] libnetwork/networkdb: remove some redundant fmt.Sprintf()'s Signed-off-by: Sebastiaan van Stijn --- libnetwork/networkdb/cluster.go | 4 ++-- libnetwork/networkdb/networkdb.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libnetwork/networkdb/cluster.go b/libnetwork/networkdb/cluster.go index ce9ad35932..49b62faea0 100644 --- a/libnetwork/networkdb/cluster.go +++ b/libnetwork/networkdb/cluster.go @@ -397,7 +397,7 @@ func (nDB *NetworkDB) reapTableEntries() { // The lock is taken at the beginning of the cycle and the deletion is inline for _, nid := range nodeNetworks { nDB.Lock() - nDB.indexes[byNetwork].WalkPrefix(fmt.Sprintf("/%s", nid), func(path string, v interface{}) bool { + nDB.indexes[byNetwork].WalkPrefix("/"+nid, func(path string, v interface{}) bool { // timeCompensation compensate in case the lock took some time to be released timeCompensation := time.Since(cycleStart) entry, ok := v.(*entry) @@ -630,7 +630,7 @@ func (nDB *NetworkDB) bulkSyncNode(networks []string, node string, unsolicited b } for _, nid := range networks { - nDB.indexes[byNetwork].WalkPrefix(fmt.Sprintf("/%s", nid), func(path string, v interface{}) bool { + nDB.indexes[byNetwork].WalkPrefix("/"+nid, func(path string, v interface{}) bool { entry, ok := v.(*entry) if !ok { return false diff --git a/libnetwork/networkdb/networkdb.go b/libnetwork/networkdb/networkdb.go index bc78e480ae..80913e9be7 100644 --- a/libnetwork/networkdb/networkdb.go +++ b/libnetwork/networkdb/networkdb.go @@ -498,7 +498,7 @@ func (nDB *NetworkDB) deleteNodeNetworkEntries(nid, node string) { // Indicates if the delete is triggered for the local node isNodeLocal := node == nDB.config.NodeID - nDB.indexes[byNetwork].WalkPrefix(fmt.Sprintf("/%s", nid), + nDB.indexes[byNetwork].WalkPrefix("/"+nid, func(path string, v interface{}) bool { oldEntry := v.(*entry) params := strings.Split(path[1:], "/") @@ -579,7 +579,7 @@ func (nDB *NetworkDB) deleteNodeTableEntries(node string) { func (nDB *NetworkDB) WalkTable(tname string, fn func(string, string, []byte, bool) bool) error { nDB.RLock() values := make(map[string]interface{}) - nDB.indexes[byTable].WalkPrefix(fmt.Sprintf("/%s", tname), func(path string, v interface{}) bool { + nDB.indexes[byTable].WalkPrefix("/"+tname, func(path string, v interface{}) bool { values[path] = v return false })