Optimize parameter passing to avoid unnecessary copying
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user