src: reduce the nearest parent package JSON cache size · nodejs/node@36b68db · GitHub
Skip to content

Commit 36b68db

Browse files
michaelsmithxyzaduh95
authored andcommitted
src: reduce the nearest parent package JSON cache size
PR-URL: #59888 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 26b40ba commit 36b68db

4 files changed

Lines changed: 52 additions & 46 deletions

File tree

lib/internal/modules/package_json_reader.js

Lines changed: 52 additions & 4 deletions

src/node_modules.cc

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -315,40 +315,6 @@ const BindingData::PackageConfig* BindingData::TraverseParent(
315315
return nullptr;
316316
}
317317

318-
void BindingData::GetNearestParentPackageJSON(
319-
const v8::FunctionCallbackInfo<v8::Value>& args) {
320-
CHECK_GE(args.Length(), 1);
321-
CHECK(args[0]->IsString());
322-
323-
Realm* realm = Realm::GetCurrent(args);
324-
BufferValue path_value(realm->isolate(), args[0]);
325-
// Check if the path has a trailing slash. If so, add it after
326-
// ToNamespacedPath() as it will be deleted by ToNamespacedPath()
327-
bool slashCheck = path_value.ToStringView().ends_with(kPathSeparator);
328-
329-
ToNamespacedPath(realm->env(), &path_value);
330-
331-
std::string path_value_str = path_value.ToString();
332-
if (slashCheck) {
333-
path_value_str.push_back(kPathSeparator);
334-
}
335-
336-
std::filesystem::path path;
337-
338-
#ifdef _WIN32
339-
std::wstring wide_path = ConvertToWideString(path_value_str, GetACP());
340-
path = std::filesystem::path(wide_path);
341-
#else
342-
path = std::filesystem::path(path_value_str);
343-
#endif
344-
345-
auto package_json = TraverseParent(realm, path);
346-
347-
if (package_json != nullptr) {
348-
args.GetReturnValue().Set(package_json->Serialize(realm));
349-
}
350-
}
351-
352318
void BindingData::GetNearestParentPackageJSONType(
353319
const FunctionCallbackInfo<Value>& args) {
354320
CHECK_GE(args.Length(), 1);
@@ -597,10 +563,6 @@ void BindingData::CreatePerIsolateProperties(IsolateData* isolate_data,
597563
target,
598564
"getNearestParentPackageJSONType",
599565
GetNearestParentPackageJSONType);
600-
SetMethod(isolate,
601-
target,
602-
"getNearestParentPackageJSON",
603-
GetNearestParentPackageJSON);
604566
SetMethod(
605567
isolate, target, "getPackageScopeConfig", GetPackageScopeConfig<false>);
606568
SetMethod(isolate, target, "getPackageType", GetPackageScopeConfig<true>);
@@ -636,7 +598,6 @@ void BindingData::RegisterExternalReferences(
636598
ExternalReferenceRegistry* registry) {
637599
registry->Register(ReadPackageJSON);
638600
registry->Register(GetNearestParentPackageJSONType);
639-
registry->Register(GetNearestParentPackageJSON);
640601
registry->Register(GetPackageScopeConfig<false>);
641602
registry->Register(GetPackageScopeConfig<true>);
642603
registry->Register(EnableCompileCache);

src/node_modules.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ class BindingData : public SnapshotableObject {
5555
SET_MEMORY_INFO_NAME(BindingData)
5656

5757
static void ReadPackageJSON(const v8::FunctionCallbackInfo<v8::Value>& args);
58-
static void GetNearestParentPackageJSON(
59-
const v8::FunctionCallbackInfo<v8::Value>& args);
6058
static void GetNearestParentPackageJSONType(
6159
const v8::FunctionCallbackInfo<v8::Value>& args);
6260
template <bool return_only_type>

typings/internalBinding/modules.d.ts

Lines changed: 0 additions & 1 deletion

0 commit comments

Comments
 (0)