GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: clean up PackageConfig pseudo-boolean fields · nodejs/node@0ca831a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • env.h
    • module_wrap.cc
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/env.h‎

Copy file name to clipboardExpand all lines: src/env.h
+10-17Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,15 @@ class Worker;
6565
namespace loader {
6666
class ModuleWrap;
6767

68-
struct Exists {
69-
enum Bool { Yes, No };
70-
};
71-
72-
struct IsValid {
73-
enum Bool { Yes, No };
74-
};
75-
76-
struct HasMain {
77-
enum Bool { Yes, No };
78-
};
79-
8068
struct PackageConfig {
81-
const Exists::Bool exists;
82-
const IsValid::Bool is_valid;
83-
const HasMain::Bool has_main;
84-
const std::string main;
69+
enum class Exists { Yes, No };
70+
enum class IsValid { Yes, No };
71+
enum class HasMain { Yes, No };
72+
73+
Exists exists;
74+
IsValid is_valid;
75+
HasMain has_main;
76+
std::string main;
8577
};
8678
} // namespace loader
8779

@@ -673,7 +665,8 @@ class Environment {
673665

674666
std::unordered_multimap<int, loader::ModuleWrap*> module_map;
675667

676-
std::unordered_map<std::string, loader::PackageConfig> package_json_cache;
668+
std::unordered_map<std::string, const loader::PackageConfig>
669+
package_json_cache;
677670

678671
inline double* heap_statistics_buffer() const;
679672
inline void set_heap_statistics_buffer(double* pointer);
Collapse file

‎src/module_wrap.cc‎

Copy file name to clipboardExpand all lines: src/module_wrap.cc
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,12 @@ Maybe<uv_file> CheckFile(const std::string& path,
488488
return Just(fd);
489489
}
490490

491+
using Exists = PackageConfig::Exists;
492+
using IsValid = PackageConfig::IsValid;
493+
using HasMain = PackageConfig::HasMain;
494+
491495
const PackageConfig& GetPackageConfig(Environment* env,
492-
const std::string path) {
496+
const std::string& path) {
493497
auto existing = env->package_json_cache.find(path);
494498
if (existing != env->package_json_cache.end()) {
495499
return existing->second;
@@ -530,7 +534,7 @@ const PackageConfig& GetPackageConfig(Environment* env,
530534
}
531535

532536
Local<Value> pkg_main;
533-
HasMain::Bool has_main = HasMain::No;
537+
HasMain has_main = HasMain::No;
534538
std::string main_std;
535539
if (pkg_json->Get(env->context(), env->main_string()).ToLocal(&pkg_main)) {
536540
has_main = HasMain::Yes;

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.