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
@@ -36,6 +36,29 @@ static void testParseInstalledOutput_emptyInput() {
|
||||
assert(pkgs.empty());
|
||||
}
|
||||
|
||||
static void testParseInstalledNames_parsesNames() {
|
||||
std::string output = "firefox 128.0\npython-pip 24.0-1\nvim 9.1.0000\n";
|
||||
auto names = PacmanManager::parseInstalledNames(output);
|
||||
|
||||
assert(names.size() == 3);
|
||||
assert(names.count("firefox") == 1);
|
||||
assert(names.count("python-pip") == 1);
|
||||
assert(names.count("vim") == 1);
|
||||
}
|
||||
|
||||
static void testParseInstalledNames_skipsEmptyLines() {
|
||||
std::string output = "firefox 128.0\n\nvim 9.1.0000\n";
|
||||
auto names = PacmanManager::parseInstalledNames(output);
|
||||
|
||||
assert(names.size() == 2);
|
||||
assert(names.count("firefox") == 1);
|
||||
assert(names.count("vim") == 1);
|
||||
}
|
||||
|
||||
static void testParseInstalledNames_emptyInput() {
|
||||
assert(PacmanManager::parseInstalledNames("").empty());
|
||||
}
|
||||
|
||||
static void testParseInstalledSizes_parsesBlocks() {
|
||||
std::string output =
|
||||
"Name : firefox\n"
|
||||
@@ -96,6 +119,10 @@ int main() {
|
||||
testParseInstalledOutput_skipsEmptyLines();
|
||||
testParseInstalledOutput_emptyInput();
|
||||
|
||||
testParseInstalledNames_parsesNames();
|
||||
testParseInstalledNames_skipsEmptyLines();
|
||||
testParseInstalledNames_emptyInput();
|
||||
|
||||
testParseInstalledSizes_parsesBlocks();
|
||||
testParseInstalledSizes_emptyInput();
|
||||
testParseSyncRepos_skipsHeader();
|
||||
|
||||
Reference in new issue
Block a user