perf(ui): fill the tables in a single repaint batch

A search result page inserted its rows one setItem() at a time, so the
viewport repainted per cell and, on the browse page, the row inserted as
"current" fired the pacman queries behind the details panel in the middle of
the fill. The fill now happens with updates disabled and the table's signals
muted, released just before the row the user actually sees is selected.

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
BlackAngelTV committed 2026-09-12 22:22:05 +02:00
1 parent 5756704b03
commit 3b4c905e7e
3 files changed
+130 -17

No files matched your search

+22
View File
@@ -1,7 +1,9 @@
#pragma once
#include "package-manager.h"
#include <chrono>
#include <map>
#include <mutex>
#include <set>
// Native Arch Linux package manager, integrated directly into the application
@@ -110,6 +112,26 @@ public:
private:
bool isPackageInstalled(const std::string& name);
// Cache for the read-only queries several views ask for in a row: a search
// runs `pacman -Q`, the Installed page runs `-Q`, `-Qi` and `-Sl`, and the
// dashboard re-runs them on every visit. Without it that is a dozen
// subprocess spawns for a single click. The window is short enough that a
// package installed outside the app still shows up almost immediately, and
// every mutating operation drops the cache outright.
struct CachedQuery {
std::string output;
std::chrono::steady_clock::time_point fetched{};
bool valid = false;
};
std::string cachedQuery(CachedQuery& slot, const char* command);
void invalidateQueries();
std::mutex m_queryMutex;
CachedQuery m_installedQuery; // pacman -Q
CachedQuery m_installedDetailsQuery; // pacman -Qi
CachedQuery m_syncReposQuery; // pacman -Sl
std::string m_password;
std::string m_lastError;
};