Skip to content

Commit b6c912b

Browse files
committed
fixup! use constexpr/consteval
1 parent cbbfdc0 commit b6c912b

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

src/node_url.cc

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -83,31 +83,31 @@ void BindingData::Deserialize(v8::Local<v8::Context> context,
8383
// @see https://www.ietf.org/rfc/rfc1738.txt 2.2. URL Character Encoding Issues
8484
constexpr auto lookup_table = []() consteval {
8585
// Each entry is an array that can hold up to 3 chars + null terminator
86-
std::array<std::array<char, 4>, LARGEST_ASCII_CHAR_CODE_TO_ENCODE + 1> result{
87-
};
86+
std::array<std::array<char, 4>, LARGEST_ASCII_CHAR_CODE_TO_ENCODE + 1>
87+
result{};
8888

8989
for (uint8_t i = 0; i <= LARGEST_ASCII_CHAR_CODE_TO_ENCODE; i++) {
9090
switch (i) {
91-
#define ENCODE_CHAR(CHAR, HEX_DIGIT_2, HEX_DIGIT_1) \
92-
case CHAR: \
93-
result[i] = {{'%', HEX_DIGIT_2, HEX_DIGIT_1, 0}}; \
94-
break; \
91+
#define ENCODE_CHAR(CHAR, HEX_DIGIT_2, HEX_DIGIT_1) \
92+
case CHAR: \
93+
result[i] = {{'%', HEX_DIGIT_2, HEX_DIGIT_1, 0}}; \
94+
break;
9595

9696
ENCODE_CHAR('\t', '0', '9') // '\t' == 0x09
9797
ENCODE_CHAR('\n', '0', 'A') // '\n' == 0x0A
9898
ENCODE_CHAR('\r', '0', 'D') // '\r' == 0x0D
99-
ENCODE_CHAR(' ', '2', '0') // ' ' == 0x20
100-
ENCODE_CHAR('"', '2', '2') // '"' == 0x22
101-
ENCODE_CHAR('#', '2', '3') // '#' == 0x23
102-
ENCODE_CHAR('%', '2', '5') // '%' == 0x25
103-
ENCODE_CHAR('?', '3', 'F') // '?' == 0x3F
104-
ENCODE_CHAR('[', '5', 'B') // '[' == 0x5B
99+
ENCODE_CHAR(' ', '2', '0') // ' ' == 0x20
100+
ENCODE_CHAR('"', '2', '2') // '"' == 0x22
101+
ENCODE_CHAR('#', '2', '3') // '#' == 0x23
102+
ENCODE_CHAR('%', '2', '5') // '%' == 0x25
103+
ENCODE_CHAR('?', '3', 'F') // '?' == 0x3F
104+
ENCODE_CHAR('[', '5', 'B') // '[' == 0x5B
105105
ENCODE_CHAR('\\', '5', 'C') // '\\' == 0x5C
106-
ENCODE_CHAR(']', '5', 'D') // ']' == 0x5D
107-
ENCODE_CHAR('^', '5', 'E') // '^' == 0x5E
108-
ENCODE_CHAR('|', '7', 'C') // '|' == 0x7C
109-
ENCODE_CHAR('~', '7', 'E') // '~' == 0x7E
110-
#undef ENCODE_CHAR
106+
ENCODE_CHAR(']', '5', 'D') // ']' == 0x5D
107+
ENCODE_CHAR('^', '5', 'E') // '^' == 0x5E
108+
ENCODE_CHAR('|', '7', 'C') // '|' == 0x7C
109+
ENCODE_CHAR('~', '7', 'E') // '~' == 0x7E
110+
#undef ENCODE_CHAR
111111

112112
default:
113113
result[i] = {{static_cast<char>(i), '\0', '\0', '\0'}};
@@ -116,7 +116,8 @@ constexpr auto lookup_table = []() consteval {
116116
}
117117

118118
return result;
119-
}();
119+
}
120+
();
120121

121122
enum class OS { WINDOWS, POSIX };
122123

0 commit comments

Comments
 (0)