pass by address

This commit is contained in:
Derek Collison
2014-04-25 13:18:50 -06:00
parent 2141cc7381
commit cd56514808

View File

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