We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3840bb5 commit 2c2b6d1Copy full SHA for 2c2b6d1
src/json_utils.cc
@@ -3,7 +3,10 @@
3
namespace node {
4
5
std::string EscapeJsonChars(std::string_view str) {
6
- static const std::string_view control_symbols[0x20] = {
+ // 'static constexpr' is slightly better than static const
7
+ // since the initialization occurs at compile time.
8
+ // See https://lemire.me/blog/I3Cah
9
+ static constexpr std::string_view control_symbols[0x20] = {
10
"\\u0000", "\\u0001", "\\u0002", "\\u0003", "\\u0004", "\\u0005",
11
"\\u0006", "\\u0007", "\\b", "\\t", "\\n", "\\u000b",
12
"\\f", "\\r", "\\u000e", "\\u000f", "\\u0010", "\\u0011",
0 commit comments