From 8f99b70eb78bdb5537afc77aa283961a2e825506 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 19 Dec 2022 16:18:18 +0200 Subject: [PATCH] Refactor the constructor of SourcePackage::Loader There isn't much point to have two differnt overloads when it could just take a nullable pointer. --- source/builder.cpp | 5 +---- source/sourcepackage.cpp | 18 +++--------------- source/sourcepackage.h | 5 ++--- 3 files changed, 6 insertions(+), 22 deletions(-) diff --git a/source/builder.cpp b/source/builder.cpp index ceb7db3..2159266 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -333,10 +333,7 @@ void Builder::Loader::package(const string &n) { SourcePackage *pkg = new SourcePackage(obj, n, get_source()); - if(options) - load_sub(*pkg, *options); - else - load_sub(*pkg); + load_sub(*pkg, options); if(obj.build_type) pkg->set_build_type(*obj.build_type); diff --git a/source/sourcepackage.cpp b/source/sourcepackage.cpp index 4d680ba..74c3886 100644 --- a/source/sourcepackage.cpp +++ b/source/sourcepackage.cpp @@ -167,23 +167,11 @@ void SourcePackage::save_caches() } -SourcePackage::Loader::Loader(SourcePackage &p): +SourcePackage::Loader::Loader(SourcePackage &p, const Config::InputOptions *o): DataFile::DerivedObjectLoader(p), - FeatureConditional(p, p.name) + FeatureConditional(p, p.name), + options(o) { - init(0); -} - -SourcePackage::Loader::Loader(SourcePackage &p, const Config::InputOptions &o): - DataFile::DerivedObjectLoader(p), - FeatureConditional(p, p.name) -{ - init(&o); -} - -void SourcePackage::Loader::init(const Config::InputOptions *o) -{ - options = o; add("android_application", &Loader::component); add("build_info", &Loader::build_info); add("datapack", &Loader::component); diff --git a/source/sourcepackage.h b/source/sourcepackage.h index dfa2f4d..68b89c8 100644 --- a/source/sourcepackage.h +++ b/source/sourcepackage.h @@ -29,11 +29,10 @@ public: const Config::InputOptions *options; public: - Loader(SourcePackage &); - Loader(SourcePackage &, const Config::InputOptions &); + Loader(SourcePackage &, const Config::InputOptions *); private: - void init(const Config::InputOptions *); void finish() override; + void feature(const std::string &, const std::string &); template void component(const std::string &); -- 2.43.0