From db554228706625eae020f5c0d92a8bcb354e4339 Mon Sep 17 00:00:00 2001 From: ocornut Date: Fri, 20 Jan 2023 17:55:50 +0100 Subject: [PATCH] Tables: removed hot RequestOutputMaskByIndex bit-array as majority of code-paths are already touching the cold parts. Only exception being TableSetColumnIndex() with same column number but that's an odd case. Will break PR #6094 #3572 #5305 #4876 but those not need to be necessarily updated: we got enough reference to finish that feature. --- imgui_internal.h | 1 - imgui_tables.cpp | 10 +++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/imgui_internal.h b/imgui_internal.h index 09886beeb..d2e00e74a 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -2538,7 +2538,6 @@ struct IMGUI_API ImGuiTable ImU64 EnabledMaskByDisplayOrder; // Column DisplayOrder -> IsEnabled map ImU64 EnabledMaskByIndex; // Column Index -> IsEnabled map (== not hidden by user/api) in a format adequate for iterating column without touching cold data ImU64 VisibleMaskByIndex; // Column Index -> IsVisibleX|IsVisibleY map (== not hidden by user/api && not hidden by scrolling/cliprect) - ImU64 RequestOutputMaskByIndex; // Column Index -> IsVisible || AutoFit (== expect user to submit items) ImGuiTableFlags SettingsLoadedFlags; // Which data were loaded from the .ini file (e.g. when order is not altered we won't save order) int SettingsOffset; // Offset in g.SettingsTables int LastFrameActive; diff --git a/imgui_tables.cpp b/imgui_tables.cpp index b6e367039..edecb20a9 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -860,7 +860,7 @@ void ImGui::TableUpdateLayout(ImGuiTable* table) // Latch initial size for fixed columns and update it constantly for auto-resizing column (unless clipped!) if (column->AutoFitQueue != 0x00) column->WidthRequest = width_auto; - else if ((column->Flags & ImGuiTableColumnFlags_WidthFixed) && !column_is_resizable && (table->RequestOutputMaskByIndex & ((ImU64)1 << column_n))) + else if ((column->Flags & ImGuiTableColumnFlags_WidthFixed) && !column_is_resizable && column->IsRequestOutput) column->WidthRequest = width_auto; // FIXME-TABLE: Increase minimum size during init frame to avoid biasing auto-fitting widgets @@ -967,7 +967,6 @@ void ImGui::TableUpdateLayout(ImGuiTable* table) ImRect host_clip_rect = table->InnerClipRect; //host_clip_rect.Max.x += table->CellPaddingX + table->CellSpacingX2; table->VisibleMaskByIndex = 0x00; - table->RequestOutputMaskByIndex = 0x00; for (int order_n = 0; order_n < table->ColumnsCount; order_n++) { const int column_n = table->DisplayOrderToIndex[order_n]; @@ -1041,8 +1040,6 @@ void ImGui::TableUpdateLayout(ImGuiTable* table) // Mark column as requesting output from user. Note that fixed + non-resizable sets are auto-fitting at all times and therefore always request output. column->IsRequestOutput = is_visible || column->AutoFitQueue != 0 || column->CannotSkipItemsQueue != 0; - if (column->IsRequestOutput) - table->RequestOutputMaskByIndex |= ((ImU64)1 << column_n); // Mark column as SkipItems (ignoring all items/layout) column->IsSkipItems = !column->IsEnabled || table->HostSkipItems; @@ -1926,7 +1923,7 @@ bool ImGui::TableSetColumnIndex(int column_n) // Return whether the column is visible. User may choose to skip submitting items based on this return value, // however they shouldn't skip submitting for columns that may have the tallest contribution to row height. - return (table->RequestOutputMaskByIndex & ((ImU64)1 << column_n)) != 0; + return table->Columns[column_n].IsRequestOutput; } // [Public] Append into the next column, wrap and create a new row when already on last column @@ -1951,8 +1948,7 @@ bool ImGui::TableNextColumn() // Return whether the column is visible. User may choose to skip submitting items based on this return value, // however they shouldn't skip submitting for columns that may have the tallest contribution to row height. - int column_n = table->CurrentColumn; - return (table->RequestOutputMaskByIndex & ((ImU64)1 << column_n)) != 0; + return table->Columns[table->CurrentColumn].IsRequestOutput; }