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

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-02-15 12:56:23 +01:00
parent abaf4b25d7
commit b9c8eca468
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
2 changed files with 4 additions and 4 deletions

View file

@ -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

View file

@ -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
})