about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/utils/twtstr.nim8
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