remove unnecessary casts

This commit is contained in:
Johann Sebastian Schicho 2021-09-05 17:56:57 +02:00
parent 6ded1b6f08
commit 648a3205bd
1 changed files with 6 additions and 6 deletions

12
bool.go
View File

@ -30,17 +30,17 @@ type AtomicBool struct {
// Set sets the Boolean to true. // Set sets the Boolean to true.
func (ab *AtomicBool) Set() { func (ab *AtomicBool) Set() {
atomic.StoreInt32((*int32)(&ab.boolean), 1) atomic.StoreInt32(&ab.boolean, 1)
} }
// UnSet sets the Boolean to false. // UnSet sets the Boolean to false.
func (ab *AtomicBool) UnSet() { func (ab *AtomicBool) UnSet() {
atomic.StoreInt32((*int32)(&ab.boolean), 0) atomic.StoreInt32(&ab.boolean, 0)
} }
// IsSet returns whether the Boolean is true. // IsSet returns whether the Boolean is true.
func (ab *AtomicBool) IsSet() bool { func (ab *AtomicBool) IsSet() bool {
return atomic.LoadInt32((*int32)(&ab.boolean))&1 == 1 return atomic.LoadInt32(&ab.boolean)&1 == 1
} }
// IsNotSet returns whether the Boolean is false. // IsNotSet returns whether the Boolean is false.
@ -51,9 +51,9 @@ func (ab *AtomicBool) IsNotSet() bool {
// SetTo sets the boolean with given Boolean. // SetTo sets the boolean with given Boolean.
func (ab *AtomicBool) SetTo(yes bool) { func (ab *AtomicBool) SetTo(yes bool) {
if yes { if yes {
atomic.StoreInt32((*int32)(&ab.boolean), 1) atomic.StoreInt32(&ab.boolean, 1)
} else { } else {
atomic.StoreInt32((*int32)(&ab.boolean), 0) atomic.StoreInt32(&ab.boolean, 0)
} }
} }
@ -79,7 +79,7 @@ func (ab *AtomicBool) SetToIf(old, new bool) (set bool) {
if new { if new {
n = 1 n = 1
} }
return atomic.CompareAndSwapInt32((*int32)(&ab.boolean), o, n) return atomic.CompareAndSwapInt32(&ab.boolean, o, n)
} }
// MarshalJSON behaves the same as if the AtomicBool is a builtin.bool. // MarshalJSON behaves the same as if the AtomicBool is a builtin.bool.