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 d863619

Browse filesBrowse files
bnoordhuisevanlucas
authored andcommitted
src: clean up PER_ISOLATE_STRING_PROPERTIES, v2
Remove strings from the PER_ISOLATE_STRING_PROPERTIES list that are only used once during initialization. It's less expensive to simply create them when needed than turn them into v8::Eternal instances. PR-URL: #8207 Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent d3950a2 commit d863619
Copy full SHA for d863619

File tree

Expand file treeCollapse file tree

3 files changed

+37
-50
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+37
-50
lines changed
Open diff view settings
Collapse file

‎src/env.h‎

Copy file name to clipboardExpand all lines: src/env.h
-15Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ namespace node {
6767
#define PER_ISOLATE_STRING_PROPERTIES(V) \
6868
V(address_string, "address") \
6969
V(args_string, "args") \
70-
V(argv_string, "argv") \
7170
V(async, "async") \
7271
V(async_queue_string, "_asyncQueue") \
7372
V(bytes_string, "bytes") \
@@ -82,8 +81,6 @@ namespace node {
8281
V(onclose_string, "_onclose") \
8382
V(code_string, "code") \
8483
V(cwd_string, "cwd") \
85-
V(debug_port_string, "debugPort") \
86-
V(debug_string, "debug") \
8784
V(dest_string, "dest") \
8885
V(detached_string, "detached") \
8986
V(disposed_string, "_disposed") \
@@ -99,8 +96,6 @@ namespace node {
9996
V(errno_string, "errno") \
10097
V(error_string, "error") \
10198
V(events_string, "_events") \
102-
V(exec_argv_string, "execArgv") \
103-
V(exec_path_string, "execPath") \
10499
V(exiting_string, "_exiting") \
105100
V(exit_code_string, "exitCode") \
106101
V(exit_string, "exit") \
@@ -115,7 +110,6 @@ namespace node {
115110
V(file_string, "file") \
116111
V(fingerprint_string, "fingerprint") \
117112
V(flags_string, "flags") \
118-
V(fsevent_string, "FSEvent") \
119113
V(gid_string, "gid") \
120114
V(handle_string, "handle") \
121115
V(heap_total_string, "heapTotal") \
@@ -129,7 +123,6 @@ namespace node {
129123
V(input_string, "input") \
130124
V(internal_string, "internal") \
131125
V(ipv4_string, "IPv4") \
132-
V(ipv6_lc_string, "ipv6") \
133126
V(ipv6_string, "IPv6") \
134127
V(isalive_string, "isAlive") \
135128
V(isclosing_string, "isClosing") \
@@ -143,7 +136,6 @@ namespace node {
143136
V(model_string, "model") \
144137
V(modulus_string, "modulus") \
145138
V(name_string, "name") \
146-
V(need_imm_cb_string, "_needImmediateCallback") \
147139
V(netmask_string, "netmask") \
148140
V(nice_string, "nice") \
149141
V(nsname_string, "nsname") \
@@ -215,19 +207,12 @@ namespace node {
215207
V(ticketkeycallback_string, "onticketkeycallback") \
216208
V(timeout_string, "timeout") \
217209
V(times_string, "times") \
218-
V(title_string, "title") \
219-
V(tls_npn_string, "tls_npn") \
220-
V(tls_alpn_string, "tls_alpn") \
221-
V(tls_ocsp_string, "tls_ocsp") \
222-
V(tls_sni_string, "tls_sni") \
223-
V(tls_string, "tls") \
224210
V(tls_ticket_string, "tlsTicket") \
225211
V(type_string, "type") \
226212
V(uid_string, "uid") \
227213
V(unknown_string, "<unknown>") \
228214
V(user_string, "user") \
229215
V(username_string, "username") \
230-
V(uv_string, "uv") \
231216
V(valid_from_string, "valid_from") \
232217
V(valid_to_string, "valid_to") \
233218
V(verify_error_string, "verifyError") \
Collapse file

‎src/fs_event_wrap.cc‎

Copy file name to clipboardExpand all lines: src/fs_event_wrap.cc
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,15 @@ void FSEventWrap::Initialize(Local<Object> target,
6565
Local<Context> context) {
6666
Environment* env = Environment::GetCurrent(context);
6767

68+
auto fsevent_string = FIXED_ONE_BYTE_STRING(env->isolate(), "FSEvent");
6869
Local<FunctionTemplate> t = env->NewFunctionTemplate(New);
6970
t->InstanceTemplate()->SetInternalFieldCount(1);
70-
t->SetClassName(env->fsevent_string());
71+
t->SetClassName(fsevent_string);
7172

7273
env->SetProtoMethod(t, "start", Start);
7374
env->SetProtoMethod(t, "close", Close);
7475

75-
target->Set(env->fsevent_string(), t->GetFunction());
76+
target->Set(fsevent_string, t->GetFunction());
7677
}
7778

7879

Collapse file

‎src/node.cc‎

Copy file name to clipboardExpand all lines: src/node.cc
+34-33Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2884,41 +2884,40 @@ static Local<Object> GetFeatures(Environment* env) {
28842884
Local<Value> debug = False(env->isolate());
28852885
#endif // defined(DEBUG) && DEBUG
28862886

2887-
obj->Set(env->debug_string(), debug);
2888-
2889-
obj->Set(env->uv_string(), True(env->isolate()));
2887+
obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "debug"), debug);
2888+
obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "uv"), True(env->isolate()));
28902889
// TODO(bnoordhuis) ping libuv
2891-
obj->Set(env->ipv6_lc_string(), True(env->isolate()));
2890+
obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "ipv6"), True(env->isolate()));
28922891

28932892
#ifdef OPENSSL_NPN_NEGOTIATED
28942893
Local<Boolean> tls_npn = True(env->isolate());
28952894
#else
28962895
Local<Boolean> tls_npn = False(env->isolate());
28972896
#endif
2898-
obj->Set(env->tls_npn_string(), tls_npn);
2897+
obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "tls_npn"), tls_npn);
28992898

29002899
#ifdef TLSEXT_TYPE_application_layer_protocol_negotiation
29012900
Local<Boolean> tls_alpn = True(env->isolate());
29022901
#else
29032902
Local<Boolean> tls_alpn = False(env->isolate());
29042903
#endif
2905-
obj->Set(env->tls_alpn_string(), tls_alpn);
2904+
obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "tls_alpn"), tls_alpn);
29062905

29072906
#ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB
29082907
Local<Boolean> tls_sni = True(env->isolate());
29092908
#else
29102909
Local<Boolean> tls_sni = False(env->isolate());
29112910
#endif
2912-
obj->Set(env->tls_sni_string(), tls_sni);
2911+
obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "tls_sni"), tls_sni);
29132912

29142913
#if !defined(OPENSSL_NO_TLSEXT) && defined(SSL_CTX_set_tlsext_status_cb)
29152914
Local<Boolean> tls_ocsp = True(env->isolate());
29162915
#else
29172916
Local<Boolean> tls_ocsp = False(env->isolate());
29182917
#endif // !defined(OPENSSL_NO_TLSEXT) && defined(SSL_CTX_set_tlsext_status_cb)
2919-
obj->Set(env->tls_ocsp_string(), tls_ocsp);
2918+
obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "tls_ocsp"), tls_ocsp);
29202919

2921-
obj->Set(env->tls_string(),
2920+
obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "tls"),
29222921
Boolean::New(env->isolate(),
29232922
get_builtin_module("crypto") != nullptr));
29242923

@@ -3044,12 +3043,12 @@ void SetupProcessObject(Environment* env,
30443043

30453044
Local<Object> process = env->process_object();
30463045

3047-
auto maybe = process->SetAccessor(env->context(),
3048-
env->title_string(),
3049-
ProcessTitleGetter,
3050-
ProcessTitleSetter,
3051-
env->as_external());
3052-
CHECK(maybe.FromJust());
3046+
auto title_string = FIXED_ONE_BYTE_STRING(env->isolate(), "title");
3047+
CHECK(process->SetAccessor(env->context(),
3048+
title_string,
3049+
ProcessTitleGetter,
3050+
ProcessTitleSetter,
3051+
env->as_external()).FromJust());
30533052

30543053
// process.version
30553054
READONLY_PROPERTY(process,
@@ -3196,14 +3195,15 @@ void SetupProcessObject(Environment* env,
31963195
for (int i = 0; i < argc; ++i) {
31973196
arguments->Set(i, String::NewFromUtf8(env->isolate(), argv[i]));
31983197
}
3199-
process->Set(env->argv_string(), arguments);
3198+
process->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "argv"), arguments);
32003199

32013200
// process.execArgv
32023201
Local<Array> exec_arguments = Array::New(env->isolate(), exec_argc);
32033202
for (int i = 0; i < exec_argc; ++i) {
32043203
exec_arguments->Set(i, String::NewFromUtf8(env->isolate(), exec_argv[i]));
32053204
}
3206-
process->Set(env->exec_argv_string(), exec_arguments);
3205+
process->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "execArgv"),
3206+
exec_arguments);
32073207

32083208
// create process.env
32093209
Local<ObjectTemplate> process_env_template =
@@ -3220,12 +3220,13 @@ void SetupProcessObject(Environment* env,
32203220

32213221
READONLY_PROPERTY(process, "pid", Integer::New(env->isolate(), getpid()));
32223222
READONLY_PROPERTY(process, "features", GetFeatures(env));
3223-
maybe = process->SetAccessor(env->context(),
3224-
env->need_imm_cb_string(),
3225-
NeedImmediateCallbackGetter,
3226-
NeedImmediateCallbackSetter,
3227-
env->as_external());
3228-
CHECK(maybe.FromJust());
3223+
3224+
auto need_immediate_callback_string =
3225+
FIXED_ONE_BYTE_STRING(env->isolate(), "_needImmediateCallback");
3226+
CHECK(process->SetAccessor(env->context(), need_immediate_callback_string,
3227+
NeedImmediateCallbackGetter,
3228+
NeedImmediateCallbackSetter,
3229+
env->as_external()).FromJust());
32293230

32303231
// -e, --eval
32313232
if (eval_string) {
@@ -3325,16 +3326,16 @@ void SetupProcessObject(Environment* env,
33253326
} else {
33263327
exec_path_value = String::NewFromUtf8(env->isolate(), argv[0]);
33273328
}
3328-
process->Set(env->exec_path_string(), exec_path_value);
3329+
process->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "execPath"),
3330+
exec_path_value);
33293331
delete[] exec_path;
33303332

3331-
maybe = process->SetAccessor(env->context(),
3332-
env->debug_port_string(),
3333-
DebugPortGetter,
3334-
DebugPortSetter,
3335-
env->as_external());
3336-
CHECK(maybe.FromJust());
3337-
3333+
auto debug_port_string = FIXED_ONE_BYTE_STRING(env->isolate(), "debugPort");
3334+
CHECK(process->SetAccessor(env->context(),
3335+
debug_port_string,
3336+
DebugPortGetter,
3337+
DebugPortSetter,
3338+
env->as_external()).FromJust());
33383339

33393340
// define various internal methods
33403341
env->SetMethod(process,
@@ -3393,8 +3394,8 @@ void SetupProcessObject(Environment* env,
33933394

33943395
// pre-set _events object for faster emit checks
33953396
Local<Object> events_obj = Object::New(env->isolate());
3396-
maybe = events_obj->SetPrototype(env->context(), Null(env->isolate()));
3397-
CHECK(maybe.FromJust());
3397+
CHECK(events_obj->SetPrototype(env->context(),
3398+
Null(env->isolate())).FromJust());
33983399
process->Set(env->events_string(), events_obj);
33993400
}
34003401

0 commit comments

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