Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5941341

Browse filesBrowse files
addaleaxaduh95
authored andcommitted
src: clean up generic counter implementation
This addresses late review comments for the recently landed cfbfc1b and aligns the new code with the pre-existing V8 fast call counters. Refs: #60434 (review) PR-URL: #60447 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent fe2d6d4 commit 5941341
Copy full SHA for 5941341

File tree

Expand file treeCollapse file tree

2 files changed

+9
-9
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+9
-9
lines changed
Open diff view settings
Collapse file

‎src/node_debug.cc‎

Copy file name to clipboardExpand all lines: src/node_debug.cc
+6-7Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,16 @@ using v8::Number;
2424
using v8::Object;
2525
using 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;
2829
thread_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

6059
void GetV8FastApiCallCount(const FunctionCallbackInfo<Value>& args) {
Collapse file

‎src/node_debug.h‎

Copy file name to clipboardExpand all lines: src/node_debug.h
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ namespace debug {
1313
void TrackV8FastApiCall(FastStringKey key);
1414
int 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))

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.