]> git.tdb.fi Git - libs/game.git/commitdiff
Remove unnecessary std::ref invocations
authorMikko Rasa <tdb@tdb.fi>
Thu, 8 Jun 2023 08:26:48 +0000 (11:26 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 8 Jun 2023 08:26:48 +0000 (11:26 +0300)
I got confused by the std::thread constructor, which stores its arguments
in a tuple and creates copies without std::ref.  It's not needed in these
cases since the arguments are just forwarded directly.

source/game/director.cpp
source/game/reflection.h

index d42daa890809cf7019ff65eee4fefffdabdb7e31..820a6fcadef53ab9fa14af3fcfc1e073efc64b92 100644 (file)
@@ -29,18 +29,18 @@ Director::~Director()
 
 Stage &Director::create_stage()
 {
-       Stage &stage = *stages.emplace_back(std::make_unique<Stage>(std::ref(reflector), std::ref(resources)));
+       Stage &stage = *stages.emplace_back(std::make_unique<Stage>(reflector, resources));
        stage.add_system<TransformPropagator>();
-       event_source.emit<Events::StageCreated>(std::ref(stage));
+       event_source.emit<Events::StageCreated>(stage);
        return stage;
 }
 
 void Director::activate_stage(Stage &s)
 {
        if(active_stage)
-               event_source.emit<Events::StageDeactivated>(std::ref(s));
+               event_source.emit<Events::StageDeactivated>(s);
        active_stage = &s;
-       event_source.emit<Events::StageActivated>(std::ref(s));
+       event_source.emit<Events::StageActivated>(s);
 }
 
 void Director::tick()
index bfd4aeb1f6745b3827c33cede98ae844de1820b8..16f2508b9f479829435e1aeec17d75ff6ec0af93 100644 (file)
@@ -128,7 +128,7 @@ inline Class<T> &Reflector::get_or_create_class()
        auto i = lower_bound(type);
        if(i==classes.end() || (*i)->get_type()!=type)
        {
-               i = classes.emplace(i, std::make_unique<Class<T>>(std::ref(*this)));
+               i = classes.emplace(i, std::make_unique<Class<T>>(*this));
                ++generation;
        }
        return static_cast<Class<T> &>(*i->get());