Skip to content

Commit 6aef60e

Browse files
committed
Simplify logic in parse_with_prefix
1 parent cdb9bbe commit 6aef60e

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

libc/src/__support/integer_literals.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,13 @@ LIBC_INLINE constexpr T parse_with_prefix(const char *ptr) {
153153
using P = Parser<T>;
154154
if (ptr == nullptr)
155155
return T();
156-
else if (ptr[0] == '0' && ptr[1] == 'x')
157-
return P::template parse<16>(ptr + 2);
158-
else if (ptr[0] == '0' && ptr[1] == 'b')
159-
return P::template parse<2>(ptr + 2);
160-
else
161-
return P::template parse<10>(ptr);
156+
if (ptr[0] == '0') {
157+
if (ptr[1] == 'b')
158+
return P::template parse<2>(ptr + 2);
159+
if (ptr[1] == 'x')
160+
return P::template parse<16>(ptr + 2);
161+
}
162+
return P::template parse<10>(ptr);
162163
}
163164

164165
} // namespace internal

0 commit comments

Comments
 (0)