Skip to content

Commit b4ee855

Browse files
Fix coding style
1 parent bf40a46 commit b4ee855

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

runtime/strings/bytes.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <gmp.h>
66
#include <stdexcept>
77
#include <unordered_set>
8+
#include <array> // Add this include for std::array
89

910
#include "runtime/alloc.h"
1011
#include "runtime/header.h"
@@ -163,12 +164,12 @@ SortBytes hook_BYTES_string2bytes(SortString s) {
163164
}
164165

165166
string *bytes2hexstring(string *b, size_t len) {
166-
static char const hexchars[] = "0123456789abcdef";
167-
auto *result
168-
= static_cast<string *>(kore_alloc_token(sizeof(string) + len * 2));
167+
static const std::array<char, 16> hexchars = {'0', '1', '2', '3', '4', '5', '6', '7',
168+
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
169+
auto *result = static_cast<string *>(kore_alloc_token(sizeof(string) + len * 2));
169170
for (size_t i = 0; i < len; i++) {
170-
result->data[i * 2] = hexchars[(*(b->data + i) >> 4) & 0xf];
171-
result->data[i * 2 + 1] = hexchars[(*(b->data + i)) & 0xf];
171+
result->data[i * 2] = hexchars.at((b->data[i] >> 4) & 0xf);
172+
result->data[i * 2 + 1] = hexchars.at(b->data[i] & 0xf);
172173
}
173174
init_with_len(result, len * 2);
174175
return result;

0 commit comments

Comments
 (0)