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
+6 -4
View File
@@ -1,12 +1,14 @@
#include "Button.hpp"
#include <utility>
#include "Label.hpp"
#include "../../core/DrawContext.hpp"
#include "../../core/Batch2D.hpp"
using namespace gui;
Button::Button(std::shared_ptr<UINode> content, glm::vec4 padding)
Button::Button(const std::shared_ptr<UINode>& content, glm::vec4 padding)
: Panel(glm::vec2(), padding, 0) {
glm::vec4 margin = getMargin();
setSize(content->getSize()+
@@ -20,9 +22,9 @@ Button::Button(std::shared_ptr<UINode> content, glm::vec4 padding)
}
Button::Button(
std::wstring text,
const std::wstring& text,
glm::vec4 padding,
onaction action,
const onaction& action,
glm::vec2 size
) : Panel(size, padding, 0)
{
@@ -63,7 +65,7 @@ std::wstring Button::getText() const {
Button* Button::textSupplier(wstringsupplier supplier) {
if (label) {
label->textSupplier(supplier);
label->textSupplier(std::move(supplier));
}
return this;
}