mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
impr: Don't reconstruct toolbar items list every frame
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user