| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent fe2d6d4 commit 5941341
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,17 +24,16 @@ using v8::Number; | |||
| 24 | 24 | using v8::Object; | |
| 25 | 25 | using v8::Value; | |
| 26 | 26 | ||
| 27 | - thread_local std::unordered_map<std::string, int> generic_usage_counters; | ||
| 27 | + thread_local std::unordered_map<FastStringKey, int, FastStringKey::Hash> | ||
| 28 | + generic_usage_counters; | ||
| 28 | 29 | thread_local std::unordered_map<FastStringKey, int, FastStringKey::Hash> | |
| 29 | 30 | v8_fast_api_call_counts; | |
| 30 | 31 | ||
| 31 | - void CountGenericUsage(const char* counter_name) { | ||
| 32 | - if (generic_usage_counters.find(counter_name) == generic_usage_counters.end()) | ||
| 33 | - generic_usage_counters[counter_name] = 0; | ||
| 32 | + void CountGenericUsage(FastStringKey counter_name) { | ||
| 34 | 33 | generic_usage_counters[counter_name]++; | |
| 35 | 34 | } | |
| 36 | 35 | ||
| 37 | - int GetGenericUsageCount(const char* counter_name) { | ||
| 36 | + int GetGenericUsageCount(FastStringKey counter_name) { | ||
| 38 | 37 | return generic_usage_counters[counter_name]; | |
| 39 | 38 | } | |
| 40 | 39 | ||
@@ -53,8 +52,8 @@ void GetGenericUsageCount(const FunctionCallbackInfo<Value>& args) { | |||
| 53 | 52 | return; | |
| 54 | 53 | } | |
| 55 | 54 | Utf8Value utf8_key(env->isolate(), args[0]); | |
| 56 | - args.GetReturnValue().Set( | ||
| 57 | - GetGenericUsageCount(utf8_key.ToStringView().data())); | ||
| 55 | + args.GetReturnValue().Set(GetGenericUsageCount( | ||
| 56 | + FastStringKey::AllowDynamic(utf8_key.ToStringView()))); | ||
| 58 | 57 | } | |
| 59 | 58 | ||
| 60 | 59 | void GetV8FastApiCallCount(const FunctionCallbackInfo<Value>& args) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,8 +13,9 @@ namespace debug { | |||
| 13 | 13 | void TrackV8FastApiCall(FastStringKey key); | |
| 14 | 14 | int GetV8FastApiCallCount(FastStringKey key); | |
| 15 | 15 | ||
| 16 | - void CountGenericUsage(const char* counter_name); | ||
| 17 | - #define COUNT_GENERIC_USAGE(name) node::debug::CountGenericUsage(name) | ||
| 16 | + void CountGenericUsage(FastStringKey counter_name); | ||
| 17 | + #define COUNT_GENERIC_USAGE(name) \ | ||
| 18 | + node::debug::CountGenericUsage(FastStringKey(name)) | ||
| 18 | 19 | ||
| 19 | 20 | #define TRACK_V8_FAST_API_CALL(key) \ | |
| 20 | 21 | node::debug::TrackV8FastApiCall(FastStringKey(key)) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments