improve file selector performance (20% in my extreme case)

This commit is contained in:
Green Sky 2024-08-13 12:30:42 +02:00
parent 08c9ba3983
commit 73afcfaaeb
No known key found for this signature in database

View File

@ -199,7 +199,11 @@ void FileSelector::render(void) {
} }
// files // files
for (auto const& dir_entry : files) { ImGuiListClipper files_clipper;
files_clipper.Begin(files.size());
while (files_clipper.Step()) {
for (int row = files_clipper.DisplayStart; row < files_clipper.DisplayEnd; row++) {
const auto& dir_entry = files.at(row);
if (ImGui::TableNextColumn()) { if (ImGui::TableNextColumn()) {
ImGui::PushID(tmp_id++); ImGui::PushID(tmp_id++);
if (ImGui::Selectable("F", false, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowItemOverlap)) { if (ImGui::Selectable("F", false, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowItemOverlap)) {
@ -228,6 +232,7 @@ void FileSelector::render(void) {
ImGui::TextDisabled("%2d.%2d.%2d - %2d:%2d", ltime->tm_mday, ltime->tm_mon, ltime->tm_year + 1900, ltime->tm_hour, ltime->tm_min); ImGui::TextDisabled("%2d.%2d.%2d - %2d:%2d", ltime->tm_mday, ltime->tm_mon, ltime->tm_year + 1900, ltime->tm_hour, ltime->tm_min);
} }
} }
}
ImGui::EndTable(); ImGui::EndTable();
} }