From 107c8c0d4d67b2e8790d41ce7cfa6c6b3606a8fc Mon Sep 17 00:00:00 2001 From: James M Snell Date: Sun, 19 Aug 2018 08:41:26 -0700 Subject: [PATCH] perf_hooks: move strings to env Move repeatedly created strings to env PR-URL: https://github.com/nodejs/node/pull/22401 Reviewed-By: Gus Caplan Reviewed-By: Tiancheng "Timothy" Gu Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen Reviewed-By: Matteo Collina Reviewed-By: Trivikram Kamat --- src/env.h | 4 ++++ src/node_perf.cc | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/env.h b/src/env.h index fa9ac7a1adb34e..5b0a04e03eec51 100644 --- a/src/env.h +++ b/src/env.h @@ -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") \ @@ -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") \ @@ -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") \ diff --git a/src/node_perf.cc b/src/node_perf.cc index 5d94bb4c8a4a56..cedb924e65eb98 100644 --- a/src/node_perf.cc +++ b/src/node_perf.cc @@ -80,7 +80,7 @@ inline void InitObject(const PerformanceEntry& entry, Local 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) @@ -88,11 +88,11 @@ inline void InitObject(const PerformanceEntry& entry, Local obj) { 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(); } @@ -249,7 +249,7 @@ void PerformanceGCCallback(Environment* env, void* ptr) { v8::PropertyAttribute attr = static_cast(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);