Skip to content

Commit 6875893

Browse files
committed
fixup!: ifs
1 parent fe74ddb commit 6875893

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

deps/nbytes/src/nbytes.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,12 @@ const int8_t unhex_table[256] = {
157157
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
158158
-1, -1, -1, -1, -1, -1, -1, -1, -1};
159159

160-
inline char nibble(uint8_t x) {
161-
return x + '0' + ((x > 9) * 39);
160+
inline constexpr char nibble(uint8_t x) {
161+
auto v = x + '0';
162+
if (x > 9) {
163+
v += 'a' - '0' - 10;
164+
}
165+
return v;
162166
}
163167

164168
size_t HexEncode(const char *src, size_t slen, char *dst, size_t dlen) {

0 commit comments

Comments
 (0)