perf(search): mark results as installed via a single pacman -Q call
tests / build-test (push) Has been cancelled
tests / build-test (push) Has been cancelled
Search previously ran one 'pacman -Qi <name>' subprocess per result, making queries with many matches (e.g. 'discord') take minutes. It now loads the installed package names once into an in-memory set and uses that set for the installed lookup.
This commit is contained in:
3 files changed
+59
-1
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "package-manager.h"
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
// Native Arch Linux package manager, integrated directly into the application
|
||||
class PacmanManager : public IPackageManager {
|
||||
@@ -29,6 +30,11 @@ public:
|
||||
// Exposed as static so the parsing can be unit-tested without invoking pacman.
|
||||
static std::vector<PackageInfo> parseInstalledOutput(const std::string& output);
|
||||
|
||||
// Parse `pacman -Q` output into a set of installed package names, used to
|
||||
// mark search results as installed without one subprocess per result.
|
||||
// Exposed as static so the parsing can be unit-tested without invoking pacman.
|
||||
static std::set<std::string> parseInstalledNames(const std::string& output);
|
||||
|
||||
// Parse `pacman -Qi` output (one block per package) into a name -> installed size map.
|
||||
// Exposed as static so the parsing can be unit-tested without invoking pacman.
|
||||
static std::map<std::string, std::string> parseInstalledSizes(const std::string& output);
|
||||
|
||||
Reference in new issue
Block a user