From 9268be4d6768555ebbb6261cf9ff24d0d998cd48 Mon Sep 17 00:00:00 2001 From: Stefano <stefano.scafiti96@gmail.com> Date: Wed, 9 Mar 2022 11:43:54 +0100 Subject: [PATCH] Implement capSet with a map[string]bool instead of map[string]struct{} --- client/handlers.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/client/handlers.go b/client/handlers.go index b799788..600f4e7 100644 --- a/client/handlers.go +++ b/client/handlers.go @@ -84,27 +84,26 @@ const ( ) type capSet struct { - caps map[string]struct{} + caps map[string]bool mu sync.RWMutex } func capabilitySet() *capSet { return &capSet{ - caps: make(map[string]struct{}), + caps: make(map[string]bool), } } func (c *capSet) Add(cap string) { c.mu.Lock() - c.caps[cap] = struct{}{} + c.caps[cap] = true c.mu.Unlock() } func (c *capSet) Has(cap string) bool { c.mu.RLock() - _, ok := c.caps[cap] - c.mu.RUnlock() - return ok + defer c.mu.RUnlock() + return c.caps[cap] } // Handler for capability negotiation commands.