remove unnecessary map lookup memeoryPeerMetadata.Put
@@ -3,15 +3,10 @@ package pstoremem
import (
"sync"
- peer "github.com/libp2p/go-libp2p-core/peer"
+ "github.com/libp2p/go-libp2p-core/peer"
pstore "github.com/libp2p/go-libp2p-core/peerstore"
)
-var internKeys = map[string]bool{
- "AgentVersion": true,
- "ProtocolVersion": true,
-}
-
type metakey struct {
id peer.ID
key string
@@ -40,7 +35,7 @@ func (ps *memoryPeerMetadata) Put(p peer.ID, key string, val interface{}) error
}
ps.dslock.Lock()
defer ps.dslock.Unlock()
- if vals, ok := val.(string); ok && internKeys[key] {
+ if vals, ok := val.(string); ok && (key == "AgentVersion" || key == "ProtocolVersion") {
if interned, ok := ps.interned[vals]; ok {
val = interned
} else {
