Skip to content

Commit

Permalink
Simplify logic in parse_with_prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
gchatelet committed Apr 4, 2024
1 parent cdb9bbe commit 6aef60e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions libc/src/__support/integer_literals.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,13 @@ LIBC_INLINE constexpr T parse_with_prefix(const char *ptr) {
using P = Parser<T>;
if (ptr == nullptr)
return T();
else if (ptr[0] == '0' && ptr[1] == 'x')
return P::template parse<16>(ptr + 2);
else if (ptr[0] == '0' && ptr[1] == 'b')
return P::template parse<2>(ptr + 2);
else
return P::template parse<10>(ptr);
if (ptr[0] == '0') {
if (ptr[1] == 'b')
return P::template parse<2>(ptr + 2);
if (ptr[1] == 'x')
return P::template parse<16>(ptr + 2);
}
return P::template parse<10>(ptr);
}

} // namespace internal
Expand Down

0 comments on commit 6aef60e

Please sign in to comment.