1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:17:35 +00:00

Assistant: Avoid creating unnecessary FileResult objects

A BinaryHeap is now used to keep track of the 6 highest scoring files.
This ensures that a FileResult is not created for a result that will
never be displayed.
This commit is contained in:
Tim Ledbetter 2023-04-12 17:38:08 +01:00 committed by Sam Atkins
parent 4043c89310
commit 6ecff2ac28
3 changed files with 19 additions and 5 deletions

View file

@ -144,8 +144,6 @@ private:
}
static constexpr size_t MAX_SEARCH_RESULTS = 6;
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(Core::System::pledge("stdio recvfd sendfd rpath cpath unix proc exec thread"));
@ -270,7 +268,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
else
app_state.selected_index = 0;
app_state.results = results;
app_state.visible_result_count = min(results.size(), MAX_SEARCH_RESULTS);
app_state.visible_result_count = min(results.size(), Assistant::MAX_SEARCH_RESULTS);
update_ui_timer->restart();
};