impr: Don't reconstruct toolbar items list every frame

This commit is contained in:
WerWolv
2024-06-25 23:14:05 +02:00
parent de24453fb9
commit c6a569ed88
5 changed files with 49 additions and 15 deletions

View File

@@ -328,12 +328,6 @@ namespace hex::plugin::builtin {
}
}
struct MenuItemSorter {
bool operator()(const auto *a, const auto *b) const {
return a->toolbarIndex < b->toolbarIndex;
}
};
void drawProviderTooltip(const prv::Provider *provider) {
if (ImGuiExt::InfoTooltip()) {
ImGui::BeginTooltip();
@@ -416,16 +410,8 @@ namespace hex::plugin::builtin {
// Toolbar items
ContentRegistry::Interface::addToolbarItem([] {
// TODO: Optimize this
std::set<const ContentRegistry::Interface::impl::MenuItem*, MenuItemSorter> menuItems;
for (const auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMenuItems()) {
if (menuItem.toolbarIndex != -1) {
menuItems.insert(&menuItem);
}
}
for (const auto &menuItem : menuItems) {
for (const auto &menuItem : ContentRegistry::Interface::impl::getToolbarMenuItems()) {
if (menuItem->unlocalizedNames.back().get() == ContentRegistry::Interface::impl::SeparatorValue) {
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
continue;