| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,10 @@ | |||
| 3 | 3 | namespace node { | |
| 4 | 4 | ||
| 5 | 5 | std::string EscapeJsonChars(std::string_view str) { | |
| 6 | - static const std::string_view control_symbols[0x20] = { | ||
| 6 | + // '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] = { | ||
| 7 | 10 | "\\u0000", "\\u0001", "\\u0002", "\\u0003", "\\u0004", "\\u0005", | |
| 8 | 11 | "\\u0006", "\\u0007", "\\b", "\\t", "\\n", "\\u000b", | |
| 9 | 12 | "\\f", "\\r", "\\u000e", "\\u000f", "\\u0010", "\\u0011", | |
| Back | FazBrowse Home | New Git URL |
0 commit comments