Skip to content

Commit

Permalink
refactored some bool impl
Browse files Browse the repository at this point in the history
  • Loading branch information
JackyWYX committed Jul 2, 2020
1 parent 3b7370b commit c3da033
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions bool.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,8 @@ func (ab *AtomicBool) Toggle() bool {
// SetToIf sets the Boolean to new only if the Boolean matches the old
// Returns whether the set was done
func (ab *AtomicBool) SetToIf(old, new bool) (set bool) {
var o, n int32
if old {
o = 1
}
if new {
n = 1
}
o := boolToInt(old)
n := boolToInt(new)
return atomic.CompareAndSwapInt32((*int32)(ab), o, n)
}

Expand Down

0 comments on commit c3da033

Please sign in to comment.