From 941515003a95e373a101608021f0d2ccaeee8881 Mon Sep 17 00:00:00 2001 From: Mike Dilger Date: Sat, 17 Feb 2024 08:29:21 +1300 Subject: [PATCH] Optimization available for when loading author-kind-replaceable events --- src/store/mod.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/store/mod.rs b/src/store/mod.rs index f939a16..dbf15b8 100644 --- a/src/store/mod.rs +++ b/src/store/mod.rs @@ -176,7 +176,7 @@ impl Store { } } else if filter.num_authors() > 0 && filter.num_kinds() > 0 { for author in filter.authors() { - for kind in filter.kinds() { + 'kind: for kind in filter.kinds() { let start_prefix = Self::key_akci( author, kind, @@ -201,6 +201,14 @@ impl Store { // check against the rest of the filter if filter.event_matches(&event)? { output.push(event); + // If kind is replaceable (and not parameterized) + // then don't take any more events for this author-kind + // pair. + // NOTE that this optimization is difficult to implement + // for other replaceable event situations + if kind.is_replaceable() { + continue 'kind; + } } } // Stop if limited