Skip to content

Commit

Permalink
perf_hooks: move strings to env
Browse files Browse the repository at this point in the history
Move repeatedly created strings to env

PR-URL: #22401
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information
jasnell authored and targos committed Sep 3, 2018
1 parent 282a45d commit 107c8c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,12 @@ struct PackageConfig {
V(dns_soa_string, "SOA") \
V(dns_srv_string, "SRV") \
V(dns_txt_string, "TXT") \
V(duration_string, "duration") \
V(emit_warning_string, "emitWarning") \
V(exchange_string, "exchange") \
V(encoding_string, "encoding") \
V(entries_string, "entries") \
V(entry_type_string, "entryType") \
V(env_pairs_string, "envPairs") \
V(errno_string, "errno") \
V(error_string, "error") \
Expand Down Expand Up @@ -186,6 +188,7 @@ struct PackageConfig {
V(issuer_string, "issuer") \
V(issuercert_string, "issuerCertificate") \
V(kill_signal_string, "killSignal") \
V(kind_string, "kind") \
V(mac_string, "mac") \
V(main_string, "main") \
V(max_buffer_string, "maxBuffer") \
Expand Down Expand Up @@ -270,6 +273,7 @@ struct PackageConfig {
V(sni_context_string, "sni_context") \
V(source_string, "source") \
V(stack_string, "stack") \
V(start_time_string, "startTime") \
V(status_string, "status") \
V(stdio_string, "stdio") \
V(subject_string, "subject") \
Expand Down
8 changes: 4 additions & 4 deletions src/node_perf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,19 @@ inline void InitObject(const PerformanceEntry& entry, Local<Object> obj) {
attr)
.FromJust();
obj->DefineOwnProperty(context,
FIXED_ONE_BYTE_STRING(isolate, "entryType"),
env->entry_type_string(),
String::NewFromUtf8(isolate,
entry.type().c_str(),
v8::NewStringType::kNormal)
.ToLocalChecked(),
attr)
.FromJust();
obj->DefineOwnProperty(context,
FIXED_ONE_BYTE_STRING(isolate, "startTime"),
env->start_time_string(),
Number::New(isolate, entry.startTime()),
attr).FromJust();
obj->DefineOwnProperty(context,
FIXED_ONE_BYTE_STRING(isolate, "duration"),
env->duration_string(),
Number::New(isolate, entry.duration()),
attr).FromJust();
}
Expand Down Expand Up @@ -249,7 +249,7 @@ void PerformanceGCCallback(Environment* env, void* ptr) {
v8::PropertyAttribute attr =
static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete);
obj->DefineOwnProperty(context,
FIXED_ONE_BYTE_STRING(env->isolate(), "kind"),
env->kind_string(),
Integer::New(env->isolate(), entry->gckind()),
attr).FromJust();
PerformanceEntry::Notify(env, entry->kind(), obj);
Expand Down

0 comments on commit 107c8c0

Please sign in to comment.