Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit daf0c78

Browse filesBrowse files
lemiretargos
authored andcommitted
src: replace static const string_view by static constexpr
PR-URL: #47524 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 57e7ed7 commit daf0c78
Copy full SHA for daf0c78

File tree

Expand file treeCollapse file tree

1 file changed

+4
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-1
lines changed
Open diff view settings
Collapse file

‎src/json_utils.cc‎

Copy file name to clipboardExpand all lines: src/json_utils.cc
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
namespace node {
44

55
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] = {
710
"\\u0000", "\\u0001", "\\u0002", "\\u0003", "\\u0004", "\\u0005",
811
"\\u0006", "\\u0007", "\\b", "\\t", "\\n", "\\u000b",
912
"\\f", "\\r", "\\u000e", "\\u000f", "\\u0010", "\\u0011",

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.