Skip to content

Commit 09a99c6

Browse files
addaleaxMylesBorins
authored andcommitted
src: mark some global state as const
Mark some global variables as `const` or `constexpr`. PR-URL: #25052 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 74e08c0 commit 09a99c6

7 files changed

+9
-9
lines changed

src/env.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class TraceEventScope {
6565
};
6666

6767
int const Environment::kNodeContextTag = 0x6e6f64;
68-
void* Environment::kNodeContextTagPtr = const_cast<void*>(
68+
void* const Environment::kNodeContextTagPtr = const_cast<void*>(
6969
static_cast<const void*>(&Environment::kNodeContextTag));
7070

7171
IsolateData::IsolateData(Isolate* isolate,

src/env.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ class Environment {
971971
uint64_t thread_id_ = 0;
972972
std::unordered_set<worker::Worker*> sub_worker_contexts_;
973973

974-
static void* kNodeContextTagPtr;
974+
static void* const kNodeContextTagPtr;
975975
static int const kNodeContextTag;
976976

977977
#if HAVE_INSPECTOR

src/node_file.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ using v8::Value;
8181
#endif
8282

8383
#ifdef __POSIX__
84-
const char* kPathSeparator = "/";
84+
constexpr char kPathSeparator = '/';
8585
#else
86-
const char* kPathSeparator = "\\/";
86+
const char* const kPathSeparator = "\\/";
8787
#endif
8888

8989
#define GET_OFFSET(a) ((a)->IsNumber() ? (a).As<Integer>()->Value() : -1)

src/node_http_parser_llhttp.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace node {
66

7-
const char* llhttp_version =
7+
const char* const llhttp_version =
88
NODE_STRINGIFY(LLHTTP_VERSION_MAJOR)
99
"."
1010
NODE_STRINGIFY(LLHTTP_VERSION_MINOR)

src/node_http_parser_traditional.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace node {
88

9-
const char* http_parser_version =
9+
const char* const http_parser_version =
1010
NODE_STRINGIFY(HTTP_PARSER_VERSION_MAJOR)
1111
"."
1212
NODE_STRINGIFY(HTTP_PARSER_VERSION_MINOR)

src/node_internals.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -697,8 +697,8 @@ static inline const char* errno_string(int errorno) {
697697

698698
extern double prog_start_time;
699699

700-
extern const char* llhttp_version;
701-
extern const char* http_parser_version;
700+
extern const char* const llhttp_version;
701+
extern const char* const http_parser_version;
702702

703703
void Abort(const v8::FunctionCallbackInfo<v8::Value>& args);
704704
void Chdir(const v8::FunctionCallbackInfo<v8::Value>& args);

src/node_postmortem_metadata.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,6 @@ int GenDebugSymbols() {
6060
return 1;
6161
}
6262

63-
int debug_symbols_generated = GenDebugSymbols();
63+
const int debug_symbols_generated = GenDebugSymbols();
6464

6565
} // namespace node

0 commit comments

Comments
 (0)