Optimize parameter passing to avoid unnecessary copying

This commit is contained in:
Pugemon
2024-06-07 04:00:38 +03:00
parent 46ca1bb04a
commit f25a425cb9
123 changed files with 578 additions and 522 deletions
+4 -3
View File
@@ -42,6 +42,7 @@
#include <glm/glm.hpp>
#include <unordered_set>
#include <functional>
#include <utility>
static debug::Logger logger("engine");
@@ -347,11 +348,11 @@ double Engine::getDelta() const {
void Engine::setScreen(std::shared_ptr<Screen> screen) {
audio::reset_channel(audio::get_channel_index("regular"));
audio::reset_channel(audio::get_channel_index("ambient"));
this->screen = screen;
this->screen = std::move(screen);
}
void Engine::setLanguage(std::string locale) {
langs::setup(paths->getResources(), locale, contentPacks);
langs::setup(paths->getResources(), std::move(locale), contentPacks);
gui->getMenu()->setPageLoader(menus::create_page_loader(this));
}
@@ -391,7 +392,7 @@ std::shared_ptr<Screen> Engine::getScreen() {
return screen;
}
void Engine::postRunnable(runnable callback) {
void Engine::postRunnable(const runnable& callback) {
std::lock_guard<std::recursive_mutex> lock(postRunnablesMutex);
postRunnables.push(callback);
}