From cce00d49b0c2962a2e39c31f6b09863c1231c7d6 Mon Sep 17 00:00:00 2001 From: bptato Date: Fri, 19 Apr 2024 17:03:06 +0200 Subject: twtstr: remove pointless checks in parseIntImpl --- src/utils/twtstr.nim | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/utils/twtstr.nim') 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 -- cgit 1.4.1-2-gfad0