Skip to content

Commit

Permalink
Return immediately if compareandswap updates the maxUidSeen. (#5224)
Browse files Browse the repository at this point in the history
Small optimiaztion to avoid reading the atomic once again after the
value is successfully updated.
  • Loading branch information
martinmr committed Apr 16, 2020
1 parent 3118269 commit 8d7c649
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion xidmap/xidmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ func (m *XidMap) updateMaxSeen(max uint64) {
if prev >= max {
return
}
atomic.CompareAndSwapUint64(&m.maxUidSeen, prev, max)
if atomic.CompareAndSwapUint64(&m.maxUidSeen, prev, max) {
return
}
}
}

Expand Down

0 comments on commit 8d7c649

Please sign in to comment.