Remove various string copies

This commit is contained in:
Evil Eye 2022-08-24 20:38:52 +02:00
parent a50b9b9876
commit 0cded25033
25 changed files with 60 additions and 65 deletions

View file

@ -27,9 +27,9 @@ namespace Gui
MyGUI::Align::Top | MyGUI::Align::Left | MyGUI::Align::Stretch, getName() + "_ScrollView");
}
void MWList::addItem(const std::string& name)
void MWList::addItem(std::string_view name)
{
mItems.push_back(name);
mItems.emplace_back(name);
}
void MWList::addSeparator()
@ -152,9 +152,11 @@ namespace Gui
eventWidgetSelected(_sender);
}
MyGUI::Button *MWList::getItemWidget(const std::string& name)
MyGUI::Button* MWList::getItemWidget(std::string_view name)
{
return mScrollView->findWidget (getName() + "_item_" + name)->castType<MyGUI::Button>();
std::string search = getName() + "_item_";
search += name;
return mScrollView->findWidget(search)->castType<MyGUI::Button>();
}
void MWList::scrollToTop()

View file

@ -36,14 +36,14 @@ namespace Gui
*/
void adjustSize();
void addItem(const std::string& name);
void addItem(std::string_view name);
void addSeparator(); ///< add a seperator between the current and the next item.
void removeItem(const std::string& name);
unsigned int getItemCount();
std::string getItemNameAt(unsigned int at); ///< \attention if there are separators, this method will return "" at the place where the separator is
void clear();
MyGUI::Button* getItemWidget(const std::string& name);
MyGUI::Button* getItemWidget(std::string_view name);
///< get widget for an item name, useful to set up tooltip
void scrollToTop();