From: Mikko Rasa Date: Thu, 8 Jun 2023 08:26:48 +0000 (+0300) Subject: Remove unnecessary std::ref invocations X-Git-Url: https://git.tdb.fi/?a=commitdiff_plain;h=6cb270c1fa7fd56c73a667ab0edb8383d4468b12;p=libs%2Fgame.git Remove unnecessary std::ref invocations 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. --- diff --git a/source/game/director.cpp b/source/game/director.cpp index d42daa8..820a6fc 100644 --- a/source/game/director.cpp +++ b/source/game/director.cpp @@ -29,18 +29,18 @@ Director::~Director() Stage &Director::create_stage() { - Stage &stage = *stages.emplace_back(std::make_unique(std::ref(reflector), std::ref(resources))); + Stage &stage = *stages.emplace_back(std::make_unique(reflector, resources)); stage.add_system(); - event_source.emit(std::ref(stage)); + event_source.emit(stage); return stage; } void Director::activate_stage(Stage &s) { if(active_stage) - event_source.emit(std::ref(s)); + event_source.emit(s); active_stage = &s; - event_source.emit(std::ref(s)); + event_source.emit(s); } void Director::tick() diff --git a/source/game/reflection.h b/source/game/reflection.h index bfd4aeb..16f2508 100644 --- a/source/game/reflection.h +++ b/source/game/reflection.h @@ -128,7 +128,7 @@ inline Class &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>(std::ref(*this))); + i = classes.emplace(i, std::make_unique>(*this)); ++generation; } return static_cast &>(*i->get());