| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d38ccaa commit 0ca831a
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -65,23 +65,15 @@ class Worker; | |||
| 65 | 65 | namespace loader { | |
| 66 | 66 | class ModuleWrap; | |
| 67 | 67 | ||
| 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 | - | ||
| 80 | 68 | 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; | ||
| 85 | 77 | }; | |
| 86 | 78 | } // namespace loader | |
| 87 | 79 | ||
@@ -673,7 +665,8 @@ class Environment { | |||
| 673 | 665 | ||
| 674 | 666 | std::unordered_multimap<int, loader::ModuleWrap*> module_map; | |
| 675 | 667 | ||
| 676 | - std::unordered_map<std::string, loader::PackageConfig> package_json_cache; | ||
| 668 | + std::unordered_map<std::string, const loader::PackageConfig> | ||
| 669 | + package_json_cache; | ||
| 677 | 670 | ||
| 678 | 671 | inline double* heap_statistics_buffer() const; | |
| 679 | 672 | inline void set_heap_statistics_buffer(double* pointer); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -488,8 +488,12 @@ Maybe<uv_file> CheckFile(const std::string& path, | |||
| 488 | 488 | return Just(fd); | |
| 489 | 489 | } | |
| 490 | 490 | ||
| 491 | + using Exists = PackageConfig::Exists; | ||
| 492 | + using IsValid = PackageConfig::IsValid; | ||
| 493 | + using HasMain = PackageConfig::HasMain; | ||
| 494 | + | ||
| 491 | 495 | const PackageConfig& GetPackageConfig(Environment* env, | |
| 492 | - const std::string path) { | ||
| 496 | + const std::string& path) { | ||
| 493 | 497 | auto existing = env->package_json_cache.find(path); | |
| 494 | 498 | if (existing != env->package_json_cache.end()) { | |
| 495 | 499 | return existing->second; | |
@@ -530,7 +534,7 @@ const PackageConfig& GetPackageConfig(Environment* env, | |||
| 530 | 534 | } | |
| 531 | 535 | ||
| 532 | 536 | Local<Value> pkg_main; | |
| 533 | - HasMain::Bool has_main = HasMain::No; | ||
| 537 | + HasMain has_main = HasMain::No; | ||
| 534 | 538 | std::string main_std; | |
| 535 | 539 | if (pkg_json->Get(env->context(), env->main_string()).ToLocal(&pkg_main)) { | |
| 536 | 540 | has_main = HasMain::Yes; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments