diff options
author | bptato <nincsnevem662@gmail.com> | 2024-04-19 17:03:06 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-04-19 17:03:06 +0200 |
commit | cce00d49b0c2962a2e39c31f6b09863c1231c7d6 (patch) | |
tree | bc16e5ea1f89abccf5a9a3251e380c33dc8adaa6 /src/utils/twtstr.nim | |
parent | c23ea622d1b34d3d290670e60e231f4f236fec50 (diff) | |
download | chawan-cce00d49b0c2962a2e39c31f6b09863c1231c7d6.tar.gz |
twtstr: remove pointless checks in parseIntImpl
Diffstat (limited to 'src/utils/twtstr.nim')
-rw-r--r-- | src/utils/twtstr.nim | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/utils/twtstr.nim b/src/utils/twtstr.nim index 713e8f40..66a211b9 100644 --- a/src/utils/twtstr.nim +++ b/src/utils/twtstr.nim @@ -326,10 +326,8 @@ func parseIntImpl[T: SomeSignedInt](s: string; allowed: set[char]; radix: T): if s[i] notin allowed: return none(T) # invalid let c = T(hexValue(s[i])) - if integer != 0: - if unlikely(T.high div radix - c < integer or - T.low div radix + c > integer): - return none(T) # overflow + if unlikely(T.high div radix - c < integer): + return none(T) # overflow integer *= radix integer += c inc i @@ -363,7 +361,7 @@ func parseUIntImpl[T: SomeUnsignedInt](s: string; allowSign: static bool; if s[i] notin allowed: return none(T) # invalid let c = T(hexValue(s[i])) - if integer != 0 and unlikely(high(T) div radix - c < integer): + if unlikely(T.high div radix - c < integer): return none(T) # overflow integer *= radix integer += c |