浏览代码

libnetwork/networkdb: remove some redundant fmt.Sprintf()'s

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 3 年之前
父节点
当前提交
b9c8eca468
共有 2 个文件被更改,包括 4 次插入4 次删除
  1. 2 2
      libnetwork/networkdb/cluster.go
  2. 2 2
      libnetwork/networkdb/networkdb.go

+ 2 - 2
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

+ 2 - 2
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
 	})