File tree Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -24,17 +24,16 @@ using v8::Number;
2424using v8::Object;
2525using v8::Value;
2626
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;
2829thread_local std::unordered_map<FastStringKey, int , FastStringKey::Hash>
2930 v8_fast_api_call_counts;
3031
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) {
3433 generic_usage_counters[counter_name]++;
3534}
3635
37- int GetGenericUsageCount (const char * counter_name) {
36+ int GetGenericUsageCount (FastStringKey counter_name) {
3837 return generic_usage_counters[counter_name];
3938}
4039
@@ -53,8 +52,8 @@ void GetGenericUsageCount(const FunctionCallbackInfo<Value>& args) {
5352 return ;
5453 }
5554 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 ())));
5857}
5958
6059void GetV8FastApiCallCount (const FunctionCallbackInfo<Value>& args) {
Original file line number Diff line number Diff line change @@ -13,8 +13,9 @@ namespace debug {
1313void TrackV8FastApiCall (FastStringKey key);
1414int GetV8FastApiCallCount (FastStringKey key);
1515
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))
1819
1920#define TRACK_V8_FAST_API_CALL (key ) \
2021 node::debug::TrackV8FastApiCall (FastStringKey(key))
You can’t perform that action at this time.
0 commit comments