mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-29 16:39:34 +08:00
Optimize inserts in vector and refactor const reference objects (#659)
Signed-off-by: German Semenov <GermanAizek@yandex.ru> Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
This commit is contained in:
@@ -27,7 +27,7 @@ namespace {
|
||||
|
||||
Element DefaultOptionTransform(const EntryState& state) {
|
||||
std::string label = (state.active ? "> " : " ") + state.label; // NOLINT
|
||||
Element e = text(label);
|
||||
Element e = text(std::move(label));
|
||||
if (state.focused) {
|
||||
e = e | inverted;
|
||||
}
|
||||
@@ -114,6 +114,7 @@ class MenuBase : public ComponentBase {
|
||||
if (option_->elements_prefix) {
|
||||
elements.push_back(option_->elements_prefix());
|
||||
}
|
||||
elements.reserve(size());
|
||||
for (int i = 0; i < size(); ++i) {
|
||||
if (i != 0 && option_->elements_infix) {
|
||||
elements.push_back(option_->elements_infix());
|
||||
@@ -362,7 +363,10 @@ class MenuBase : public ComponentBase {
|
||||
animator_background_.clear();
|
||||
animator_foreground_.clear();
|
||||
|
||||
for (int i = 0; i < size(); ++i) {
|
||||
const int len = size();
|
||||
animator_background_.reserve(len);
|
||||
animator_foreground_.reserve(len);
|
||||
for (int i = 0; i < len; ++i) {
|
||||
animation_background_[i] = 0.F;
|
||||
animation_foreground_[i] = 0.F;
|
||||
animator_background_.emplace_back(&animation_background_[i], 0.F,
|
||||
|
Reference in New Issue
Block a user