Skip to content

Commit

Permalink
refactor(deps): Use bit-shift instead of multiplication in parse_num.c
Browse files Browse the repository at this point in the history
  • Loading branch information
jpfr committed Jan 2, 2024
1 parent 38bd66d commit d9f1ee2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions deps/parse_num.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ parseUInt64(const char *str, size_t size, uint64_t *result) {
for(; i < size; i++) {
if(str[i] < '0' || str[i] > '9')
break;
n *= 10;
n +=(uint8_t)(str[i] - '0');
/* Fast multiplication: n*10 == (n*8) + (n*2) */
n = (n << 3) + (n << 1) + (uint8_t)(str[i] - '0');
if(n < prev) /* Check for overflow */
return 0;
prev = n;
Expand Down

0 comments on commit d9f1ee2

Please sign in to comment.