Skip to content

Commit

Permalink
Remove ineffective else clauses (#464)
Browse files Browse the repository at this point in the history
  • Loading branch information
TristonianJones authored Oct 19, 2021
1 parent d05b00f commit 8e5d987
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 54 deletions.
24 changes: 12 additions & 12 deletions common/types/duration.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,18 @@ func (d Duration) Add(other ref.Val) ref.Val {
switch other.Type() {
case DurationType:
dur2 := other.(Duration)
if val, err := addDurationChecked(d.Duration, dur2.Duration); err != nil {
val, err := addDurationChecked(d.Duration, dur2.Duration)
if err != nil {
return wrapErr(err)
} else {
return durationOf(val)
}
return durationOf(val)
case TimestampType:
ts := other.(Timestamp).Time
if val, err := addTimeDurationChecked(ts, d.Duration); err != nil {
val, err := addTimeDurationChecked(ts, d.Duration)
if err != nil {
return wrapErr(err)
} else {
return timestampOf(val)
}
return timestampOf(val)
}
return MaybeNoSuchOverloadErr(other)
}
Expand Down Expand Up @@ -143,11 +143,11 @@ func (d Duration) Equal(other ref.Val) ref.Val {

// Negate implements traits.Negater.Negate.
func (d Duration) Negate() ref.Val {
if val, err := negateDurationChecked(d.Duration); err != nil {
val, err := negateDurationChecked(d.Duration)
if err != nil {
return wrapErr(err)
} else {
return durationOf(val)
}
return durationOf(val)
}

// Receive implements traits.Receiver.Receive.
Expand All @@ -166,11 +166,11 @@ func (d Duration) Subtract(subtrahend ref.Val) ref.Val {
if !ok {
return MaybeNoSuchOverloadErr(subtrahend)
}
if val, err := subtractDurationChecked(d.Duration, subtraDur.Duration); err != nil {
val, err := subtractDurationChecked(d.Duration, subtraDur.Duration)
if err != nil {
return wrapErr(err)
} else {
return durationOf(val)
}
return durationOf(val)
}

// Type implements ref.Val.Type.
Expand Down
36 changes: 18 additions & 18 deletions common/types/int.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ func (i Int) Add(other ref.Val) ref.Val {
if !ok {
return MaybeNoSuchOverloadErr(other)
}
if val, err := addInt64Checked(int64(i), int64(otherInt)); err != nil {
val, err := addInt64Checked(int64(i), int64(otherInt))
if err != nil {
return wrapErr(err)
} else {
return Int(val)
}
return Int(val)
}

// Compare implements traits.Comparer.Compare.
Expand Down Expand Up @@ -199,11 +199,11 @@ func (i Int) Divide(other ref.Val) ref.Val {
if !ok {
return MaybeNoSuchOverloadErr(other)
}
if val, err := divideInt64Checked(int64(i), int64(otherInt)); err != nil {
val, err := divideInt64Checked(int64(i), int64(otherInt))
if err != nil {
return wrapErr(err)
} else {
return Int(val)
}
return Int(val)
}

// Equal implements ref.Val.Equal.
Expand All @@ -221,11 +221,11 @@ func (i Int) Modulo(other ref.Val) ref.Val {
if !ok {
return MaybeNoSuchOverloadErr(other)
}
if val, err := moduloInt64Checked(int64(i), int64(otherInt)); err != nil {
val, err := moduloInt64Checked(int64(i), int64(otherInt))
if err != nil {
return wrapErr(err)
} else {
return Int(val)
}
return Int(val)
}

// Multiply implements traits.Multiplier.Multiply.
Expand All @@ -234,20 +234,20 @@ func (i Int) Multiply(other ref.Val) ref.Val {
if !ok {
return MaybeNoSuchOverloadErr(other)
}
if val, err := multiplyInt64Checked(int64(i), int64(otherInt)); err != nil {
val, err := multiplyInt64Checked(int64(i), int64(otherInt))
if err != nil {
return wrapErr(err)
} else {
return Int(val)
}
return Int(val)
}

// Negate implements traits.Negater.Negate.
func (i Int) Negate() ref.Val {
if val, err := negateInt64Checked(int64(i)); err != nil {
val, err := negateInt64Checked(int64(i))
if err != nil {
return wrapErr(err)
} else {
return Int(val)
}
return Int(val)
}

// Subtract implements traits.Subtractor.Subtract.
Expand All @@ -256,11 +256,11 @@ func (i Int) Subtract(subtrahend ref.Val) ref.Val {
if !ok {
return MaybeNoSuchOverloadErr(subtrahend)
}
if val, err := subtractInt64Checked(int64(i), int64(subtraInt)); err != nil {
val, err := subtractInt64Checked(int64(i), int64(subtraInt))
if err != nil {
return wrapErr(err)
} else {
return Int(val)
}
return Int(val)
}

// Type implements ref.Val.Type.
Expand Down
12 changes: 6 additions & 6 deletions common/types/timestamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,18 @@ func (t Timestamp) Subtract(subtrahend ref.Val) ref.Val {
switch subtrahend.Type() {
case DurationType:
dur := subtrahend.(Duration)
if val, err := subtractTimeDurationChecked(t.Time, dur.Duration); err != nil {
val, err := subtractTimeDurationChecked(t.Time, dur.Duration)
if err != nil {
return wrapErr(err)
} else {
return timestampOf(val)
}
return timestampOf(val)
case TimestampType:
t2 := subtrahend.(Timestamp).Time
if val, err := subtractTimeChecked(t.Time, t2); err != nil {
val, err := subtractTimeChecked(t.Time, t2)
if err != nil {
return wrapErr(err)
} else {
return durationOf(val)
}
return durationOf(val)
}
return MaybeNoSuchOverloadErr(subtrahend)
}
Expand Down
36 changes: 18 additions & 18 deletions common/types/uint.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ func (i Uint) Add(other ref.Val) ref.Val {
if !ok {
return MaybeNoSuchOverloadErr(other)
}
if val, err := addUint64Checked(uint64(i), uint64(otherUint)); err != nil {
val, err := addUint64Checked(uint64(i), uint64(otherUint))
if err != nil {
return wrapErr(err)
} else {
return Uint(val)
}
return Uint(val)
}

// Compare implements traits.Comparer.Compare.
Expand Down Expand Up @@ -144,11 +144,11 @@ func (i Uint) ConvertToNative(typeDesc reflect.Type) (interface{}, error) {
func (i Uint) ConvertToType(typeVal ref.Type) ref.Val {
switch typeVal {
case IntType:
if v, err := uint64ToInt64Checked(uint64(i)); err != nil {
v, err := uint64ToInt64Checked(uint64(i))
if err != nil {
return wrapErr(err)
} else {
return Int(v)
}
return Int(v)
case UintType:
return i
case DoubleType:
Expand All @@ -167,11 +167,11 @@ func (i Uint) Divide(other ref.Val) ref.Val {
if !ok {
return MaybeNoSuchOverloadErr(other)
}
if div, err := divideUint64Checked(uint64(i), uint64(otherUint)); err != nil {
div, err := divideUint64Checked(uint64(i), uint64(otherUint))
if err != nil {
return wrapErr(err)
} else {
return Uint(div)
}
return Uint(div)
}

// Equal implements ref.Val.Equal.
Expand All @@ -189,11 +189,11 @@ func (i Uint) Modulo(other ref.Val) ref.Val {
if !ok {
return MaybeNoSuchOverloadErr(other)
}
if mod, err := moduloUint64Checked(uint64(i), uint64(otherUint)); err != nil {
mod, err := moduloUint64Checked(uint64(i), uint64(otherUint))
if err != nil {
return wrapErr(err)
} else {
return Uint(mod)
}
return Uint(mod)
}

// Multiply implements traits.Multiplier.Multiply.
Expand All @@ -202,11 +202,11 @@ func (i Uint) Multiply(other ref.Val) ref.Val {
if !ok {
return MaybeNoSuchOverloadErr(other)
}
if val, err := multiplyUint64Checked(uint64(i), uint64(otherUint)); err != nil {
val, err := multiplyUint64Checked(uint64(i), uint64(otherUint))
if err != nil {
return wrapErr(err)
} else {
return Uint(val)
}
return Uint(val)
}

// Subtract implements traits.Subtractor.Subtract.
Expand All @@ -215,11 +215,11 @@ func (i Uint) Subtract(subtrahend ref.Val) ref.Val {
if !ok {
return MaybeNoSuchOverloadErr(subtrahend)
}
if val, err := subtractUint64Checked(uint64(i), uint64(subtraUint)); err != nil {
val, err := subtractUint64Checked(uint64(i), uint64(subtraUint))
if err != nil {
return wrapErr(err)
} else {
return Uint(val)
}
return Uint(val)
}

// Type implements ref.Val.Type.
Expand Down

0 comments on commit 8e5d987

Please sign in to comment.