summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-06-13 11:22:57 -0400
committerJune McEnroe <june@causal.agency>2021-06-13 11:22:57 -0400
commita18b3d324f2861666872bd3cdf2e5db1583044cf (patch)
tree410998fcbc980179421c17b837139f8129325345
parentSort and compress export fetch UIDs (diff)
downloadbubger-a18b3d324f2861666872bd3cdf2e5db1583044cf.tar.gz
bubger-a18b3d324f2861666872bd3cdf2e5db1583044cf.zip
Avoid performing a SEARCH for ALL
-rw-r--r--archive.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/archive.c b/archive.c
index 20ea5d0..4c0e9da 100644
--- a/archive.c
+++ b/archive.c
@@ -136,6 +136,17 @@ static void searchThreads(
 	struct Resp resp;
 	struct List roots = {0};
 
+	if (!strcmp(expr, "ALL")) {
+		for (size_t i = 0; i < threads.len; ++i) {
+			struct Data root = {
+				.type = Number,
+				.number = threadRoot(dataCheck(threads.ptr[i], List).list)
+			};
+			listPush(&roots, root);
+		}
+		goto concat;
+	}
+
 	enum Atom search = atom("search");
 	concatSearch(imap->w, search, threads, expr);
 	for (; resp = respOk(imapResp(imap)), resp.tag != search; respFree(resp)) {
@@ -145,6 +156,7 @@ static void searchThreads(
 	}
 	respFree(resp);
 
+concat:
 	concatIndex(name, roots, threads, envelopes);
 	listFree(roots);
 }