mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
Optimize parameter passing to avoid unnecessary copying
This commit is contained in:
parent
46ca1bb04a
commit
f25a425cb9
123 changed files with 578 additions and 522 deletions
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
using namespace gui;
|
||||
|
||||
|
|
@ -221,18 +222,18 @@ bool GUI::isFocusCaught() const {
|
|||
}
|
||||
|
||||
void GUI::add(std::shared_ptr<UINode> node) {
|
||||
container->add(node);
|
||||
container->add(std::move(node));
|
||||
}
|
||||
|
||||
void GUI::remove(std::shared_ptr<UINode> node) noexcept {
|
||||
container->remove(node);
|
||||
container->remove(std::move(node));
|
||||
}
|
||||
|
||||
void GUI::store(std::string name, std::shared_ptr<UINode> node) {
|
||||
storage[name] = node;
|
||||
void GUI::store(const std::string& name, std::shared_ptr<UINode> node) {
|
||||
storage[name] = std::move(node);
|
||||
}
|
||||
|
||||
std::shared_ptr<UINode> GUI::get(std::string name) noexcept {
|
||||
std::shared_ptr<UINode> GUI::get(const std::string& name) noexcept {
|
||||
auto found = storage.find(name);
|
||||
if (found == storage.end()) {
|
||||
return nullptr;
|
||||
|
|
@ -240,7 +241,7 @@ std::shared_ptr<UINode> GUI::get(std::string name) noexcept {
|
|||
return found->second;
|
||||
}
|
||||
|
||||
void GUI::remove(std::string name) noexcept {
|
||||
void GUI::remove(const std::string& name) noexcept {
|
||||
storage.erase(name);
|
||||
}
|
||||
|
||||
|
|
@ -248,7 +249,7 @@ void GUI::setFocus(std::shared_ptr<UINode> node) {
|
|||
if (focus) {
|
||||
focus->defocus();
|
||||
}
|
||||
focus = node;
|
||||
focus = std::move(node);
|
||||
if (focus) {
|
||||
focus->onFocus(this);
|
||||
}
|
||||
|
|
@ -258,7 +259,7 @@ std::shared_ptr<Container> GUI::getContainer() const {
|
|||
return container;
|
||||
}
|
||||
|
||||
void GUI::postRunnable(runnable callback) {
|
||||
void GUI::postRunnable(const runnable& callback) {
|
||||
postRunnables.push(callback);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue