mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
pass by address
This commit is contained in:
@@ -24,7 +24,7 @@ func BenchmarkParseSize(b *testing.B) {
|
||||
}
|
||||
}
|
||||
|
||||
func deferUnlock(mu sync.Mutex) {
|
||||
func deferUnlock(mu *sync.Mutex) {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
}
|
||||
@@ -33,11 +33,11 @@ func BenchmarkDeferMutex(b *testing.B) {
|
||||
var mu sync.Mutex
|
||||
b.SetBytes(1)
|
||||
for i := 0; i < b.N; i++ {
|
||||
deferUnlock(mu)
|
||||
deferUnlock(&mu)
|
||||
}
|
||||
}
|
||||
|
||||
func noDeferUnlock(mu sync.Mutex) {
|
||||
func noDeferUnlock(mu *sync.Mutex) {
|
||||
mu.Lock()
|
||||
mu.Unlock()
|
||||
}
|
||||
@@ -46,6 +46,6 @@ func BenchmarkNoDeferMutex(b *testing.B) {
|
||||
var mu sync.Mutex
|
||||
b.SetBytes(1)
|
||||
for i := 0; i < b.N; i++ {
|
||||
noDeferUnlock(mu)
|
||||
noDeferUnlock(&mu)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user