clist: speedup Next by removing defers (#2511)

This change doubles the speed of the mempool's reaping.
Before:

BenchmarkReap-8   	    5000	    365390 ns/op	  122887 B/op

After:

BenchmarkReap-8   	   10000	    158274 ns/op	  122882 B/op
This commit is contained in:
Dev Ojha
2018-09-30 13:26:14 -04:00
committed by Ethan Buchman
parent ead9fc0179
commit 69c7aa77bc
3 changed files with 58 additions and 32 deletions
+3 -3
View File
@@ -113,9 +113,9 @@ func (e *CElement) NextWaitChan() <-chan struct{} {
// Nonblocking, may return nil if at the end.
func (e *CElement) Next() *CElement {
e.mtx.RLock()
defer e.mtx.RUnlock()
return e.next
val := e.next
e.mtx.RUnlock()
return val
}
// Nonblocking, may return nil if at the end.