]> git.tdb.fi Git - builder.git/commitdiff
Refactor the constructor of SourcePackage::Loader
authorMikko Rasa <tdb@tdb.fi>
Mon, 19 Dec 2022 14:18:18 +0000 (16:18 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 19 Dec 2022 17:19:09 +0000 (19:19 +0200)
There isn't much point to have two differnt overloads when it could just
take a nullable pointer.

source/builder.cpp
source/sourcepackage.cpp
source/sourcepackage.h

index ceb7db3581f7db02915b8433fdfda56532657811..21592661624742d5085d48a73a1c4ccf76e79572 100644 (file)
@@ -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);
index 4d680ba9bd234e5d16e62ea76adda82bf8a89c2e..74c38864bce10cb4f63bdd5888604b0f69841365 100644 (file)
@@ -167,23 +167,11 @@ void SourcePackage::save_caches()
 }
 
 
-SourcePackage::Loader::Loader(SourcePackage &p):
+SourcePackage::Loader::Loader(SourcePackage &p, const Config::InputOptions *o):
        DataFile::DerivedObjectLoader<SourcePackage, Package::Loader>(p),
-       FeatureConditional(p, p.name)
+       FeatureConditional(p, p.name),
+       options(o)
 {
-       init(0);
-}
-
-SourcePackage::Loader::Loader(SourcePackage &p, const Config::InputOptions &o):
-       DataFile::DerivedObjectLoader<SourcePackage, Package::Loader>(p),
-       FeatureConditional(p, p.name)
-{
-       init(&o);
-}
-
-void SourcePackage::Loader::init(const Config::InputOptions *o)
-{
-       options = o;
        add("android_application", &Loader::component<AndroidApplicationComponent>);
        add("build_info",  &Loader::build_info);
        add("datapack",    &Loader::component<DataPackComponent>);
index dfa2f4d295a921072f58460c1a0713ba52134984..68b89c85279e4ab9327be954b457f4f8a2742de2 100644 (file)
@@ -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<typename C>
                void component(const std::string &);