mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Manually unlock the mutex in ClientMap.SendQueue.
Rather than use defer. It is only a tiny amount faster, but this function is frequently called. Before: $ go test -bench=BenchmarkSendQueue -benchtime=2s BenchmarkSendQueue-4 15901834 151 ns/op After: $ go test -bench=BenchmarkSendQueue -benchtime=2s BenchmarkSendQueue-4 15859948 147 ns/op https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/issues/40177
This commit is contained in:
parent
8e5af50bdb
commit
64491466ce
2 changed files with 21 additions and 2 deletions
|
@ -57,8 +57,9 @@ func NewClientMap(timeout time.Duration) *ClientMap {
|
|||
// necessary.
|
||||
func (m *ClientMap) SendQueue(addr net.Addr) chan []byte {
|
||||
m.lock.Lock()
|
||||
defer m.lock.Unlock()
|
||||
return m.inner.SendQueue(addr, time.Now())
|
||||
queue := m.inner.SendQueue(addr, time.Now())
|
||||
m.lock.Unlock()
|
||||
return queue
|
||||
}
|
||||
|
||||
// clientMapInner is the inner type of ClientMap, implementing heap.Interface.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue