From 6393b0cbc0616c7bcc402d0185fa5a0a96c49d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Sat, 16 Feb 2019 16:52:56 +0100 Subject: [PATCH] feat: Prefer binary to exponential search --- src/database/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/database/mod.rs b/src/database/mod.rs index c23e5000f..7577254fc 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -131,7 +131,7 @@ fn merge_ranked_maps(existing: Option<&[u8]>, operands: &mut MergeOperands) -> V let mut ranked_map = RankedMap::default(); for bytes in existing.into_iter().chain(operands) { match ReadRankedMapEvent::from_bytes(bytes.to_vec()).unwrap() { - RemovedDocuments(d) => ranked_map.retain(|(k, _), _| !d.as_ref().contains(k)), + RemovedDocuments(d) => ranked_map.retain(|(k, _), _| !d.as_ref().binary_search(k).is_ok()), UpdatedDocuments(i) => ranked_map.extend(i), } }