src: use `FastStringKey` for `TrackV8FastApiCall` · nodejs/node@77649ad

Original file line numberDiff line numberDiff line change

@@ -23,13 +23,14 @@ using v8::Number;

2323

using v8::Object;

2424

using v8::Value;

2525
26-

thread_local std::unordered_map<std::string_view, int> v8_fast_api_call_counts;

26+

thread_local std::unordered_map<FastStringKey, int, FastStringKey::Hash>

27+

v8_fast_api_call_counts;

2728
28-

void TrackV8FastApiCall(std::string_view key) {

29+

void TrackV8FastApiCall(FastStringKey key) {

2930

v8_fast_api_call_counts[key]++;

3031

}

3132
32-

int GetV8FastApiCallCount(std::string_view key) {

33+

int GetV8FastApiCallCount(FastStringKey key) {

3334

return v8_fast_api_call_counts[key];

3435

}

3536

@@ -40,7 +41,8 @@ void GetV8FastApiCallCount(const FunctionCallbackInfo<Value>& args) {

4041

return;

4142

}

4243

Utf8Value utf8_key(env->isolate(), args[0]);

43-

args.GetReturnValue().Set(GetV8FastApiCallCount(utf8_key.ToStringView()));

44+

args.GetReturnValue().Set(GetV8FastApiCallCount(

45+

FastStringKey::AllowDynamic(utf8_key.ToStringView())));

4446

}

4547
4648

void SlowIsEven(const FunctionCallbackInfo<Value>& args) {