Skip to content

Commit 107c8c0

Browse files
jasnelltargos
authored andcommitted
perf_hooks: move strings to env
Move repeatedly created strings to env PR-URL: #22401 Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent 282a45d commit 107c8c0

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/env.h

+4
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,12 @@ struct PackageConfig {
147147
V(dns_soa_string, "SOA") \
148148
V(dns_srv_string, "SRV") \
149149
V(dns_txt_string, "TXT") \
150+
V(duration_string, "duration") \
150151
V(emit_warning_string, "emitWarning") \
151152
V(exchange_string, "exchange") \
152153
V(encoding_string, "encoding") \
153154
V(entries_string, "entries") \
155+
V(entry_type_string, "entryType") \
154156
V(env_pairs_string, "envPairs") \
155157
V(errno_string, "errno") \
156158
V(error_string, "error") \
@@ -186,6 +188,7 @@ struct PackageConfig {
186188
V(issuer_string, "issuer") \
187189
V(issuercert_string, "issuerCertificate") \
188190
V(kill_signal_string, "killSignal") \
191+
V(kind_string, "kind") \
189192
V(mac_string, "mac") \
190193
V(main_string, "main") \
191194
V(max_buffer_string, "maxBuffer") \
@@ -270,6 +273,7 @@ struct PackageConfig {
270273
V(sni_context_string, "sni_context") \
271274
V(source_string, "source") \
272275
V(stack_string, "stack") \
276+
V(start_time_string, "startTime") \
273277
V(status_string, "status") \
274278
V(stdio_string, "stdio") \
275279
V(subject_string, "subject") \

src/node_perf.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,19 @@ inline void InitObject(const PerformanceEntry& entry, Local<Object> obj) {
8080
attr)
8181
.FromJust();
8282
obj->DefineOwnProperty(context,
83-
FIXED_ONE_BYTE_STRING(isolate, "entryType"),
83+
env->entry_type_string(),
8484
String::NewFromUtf8(isolate,
8585
entry.type().c_str(),
8686
v8::NewStringType::kNormal)
8787
.ToLocalChecked(),
8888
attr)
8989
.FromJust();
9090
obj->DefineOwnProperty(context,
91-
FIXED_ONE_BYTE_STRING(isolate, "startTime"),
91+
env->start_time_string(),
9292
Number::New(isolate, entry.startTime()),
9393
attr).FromJust();
9494
obj->DefineOwnProperty(context,
95-
FIXED_ONE_BYTE_STRING(isolate, "duration"),
95+
env->duration_string(),
9696
Number::New(isolate, entry.duration()),
9797
attr).FromJust();
9898
}
@@ -249,7 +249,7 @@ void PerformanceGCCallback(Environment* env, void* ptr) {
249249
v8::PropertyAttribute attr =
250250
static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete);
251251
obj->DefineOwnProperty(context,
252-
FIXED_ONE_BYTE_STRING(env->isolate(), "kind"),
252+
env->kind_string(),
253253
Integer::New(env->isolate(), entry->gckind()),
254254
attr).FromJust();
255255
PerformanceEntry::Notify(env, entry->kind(), obj);

0 commit comments

Comments
 (0)