Skip to content

Commit

Permalink
Removes redundant booleans
Browse files Browse the repository at this point in the history
After the if clause (shift >= 128) fails, it is ensured that shift is less than 128 when it reaches that part of the code, hence (128 > shift) is the same as (shift < 128) which is always true and can be removed from both clauses.
  • Loading branch information
gilnobrega committed Jul 26, 2021
1 parent 32c7afa commit 4fcd6c6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions uint128_t/uint128_t.cpp
Expand Up @@ -157,7 +157,7 @@ uint128_t uint128_t::operator<<(const uint128_t & rhs) const{
else if (shift < 64){
return uint128_t((UPPER << shift) + (LOWER >> (64 - shift)), LOWER << shift);
}
else if ((128 > shift) && (shift > 64)){
else if (shift > 64) {
return uint128_t(LOWER << (shift - 64), 0);
}
else{
Expand All @@ -184,7 +184,7 @@ uint128_t uint128_t::operator>>(const uint128_t & rhs) const{
else if (shift < 64){
return uint128_t(UPPER >> shift, (UPPER << (64 - shift)) + (LOWER >> shift));
}
else if ((128 > shift) && (shift > 64)){
else if (shift > 64) {
return uint128_t(0, (UPPER >> (shift - 64)));
}
else{
Expand Down

0 comments on commit 4fcd6c6

Please sign in to comment.