1
0
mirror of synced 2025-01-19 01:24:15 +01:00

impr: Optimize frame times

This commit is contained in:
WerWolv 2024-06-25 13:54:46 +02:00
parent ba7c10f4b1
commit 4bc724791d
5 changed files with 10 additions and 8 deletions

View File

@ -145,7 +145,7 @@ namespace hex::log {
} }
void assertionHandler(bool expr, const char* exprString, const char* file, int line) { void assertionHandler(bool expr, const char* exprString, const char* file, int line) {
if (!expr) { if (!expr) [[unlikely]] {
log::error("Assertion failed: {} at {}:{}", exprString, file, line); log::error("Assertion failed: {} at {}:{}", exprString, file, line);
#if defined (DEBUG) #if defined (DEBUG)

View File

@ -71,7 +71,7 @@ namespace hex {
} }
std::string View::toWindowName(const UnlocalizedString &unlocalizedName) { std::string View::toWindowName(const UnlocalizedString &unlocalizedName) {
return Lang(unlocalizedName) + "###" + unlocalizedName.get(); return fmt::format("{}###{}", Lang(unlocalizedName), unlocalizedName.get());
} }
} }

View File

@ -416,6 +416,7 @@ namespace hex::plugin::builtin {
// Toolbar items // Toolbar items
ContentRegistry::Interface::addToolbarItem([] { ContentRegistry::Interface::addToolbarItem([] {
// TODO: Optimize this
std::set<const ContentRegistry::Interface::impl::MenuItem*, MenuItemSorter> menuItems; std::set<const ContentRegistry::Interface::impl::MenuItem*, MenuItemSorter> menuItems;
for (const auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMenuItems()) { for (const auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMenuItems()) {

View File

@ -279,18 +279,17 @@ namespace hex::plugin::builtin {
toolbarIndex toolbarIndex
] = menuItem; ] = menuItem;
createNestedMenu(unlocalizedNames, icon.glyph.c_str(), *shortcut, callback, enabledCallback, selectedCallack); createNestedMenu(unlocalizedNames | std::views::drop(1), icon.glyph.c_str(), *shortcut, callback, enabledCallback, selectedCallack);
} }
} }
void defineMenu(const UnlocalizedString &menuName) { void defineMenu(const UnlocalizedString &menuName) {
ImGui::GetStyle().TouchExtraPadding = scaled(ImVec2(0, 2)); ImGui::GetStyle().TouchExtraPadding = scaled(ImVec2(0, 2));
if (ImGui::BeginMenu(Lang(menuName))) { if (ImGui::BeginMenu(Lang(menuName))) {
populateMenu(menuName);
ImGui::EndMenu(); ImGui::EndMenu();
} }
ImGui::GetStyle().TouchExtraPadding = ImVec2(0, 0); ImGui::GetStyle().TouchExtraPadding = ImVec2(0, 0);
populateMenu(menuName);
} }
void drawMenu() { void drawMenu() {

View File

@ -24,9 +24,11 @@ namespace hex::ui {
hex::unused(address, upperCase); hex::unused(address, upperCase);
if (size == 1) { if (size == 1) {
const u8 c = data[0]; const char c = char(data[0]);
if (std::isprint(c) != 0) if (std::isprint(c) != 0) {
ImGui::Text("%c", c); const std::array<char, 2> string = { c, 0x00 };
ImGui::TextUnformatted(string.data());
}
else else
ImGui::TextDisabled("."); ImGui::TextDisabled(".");
} else { } else {