From 10bd0a18592b39a65025750b23cbb5b74ffa5f6d Mon Sep 17 00:00:00 2001 From: ppom Date: Fri, 8 Aug 2025 12:00:00 +0200 Subject: [PATCH] Tree::fetch_update: Do not remove and re-add entries. Better cloning the value than writing another entry! --- TODO | 1 + src/treedb/mod.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index dfa721f..5f13e77 100644 --- a/TODO +++ b/TODO @@ -6,3 +6,4 @@ should an ipv6-mapped ipv4 match a pattern of type ipv6? should it be normalized as ipv4 then? fix filter commands executing before start commands +fix order of db write subject to race condition (make writes async?) diff --git a/src/treedb/mod.rs b/src/treedb/mod.rs index 8549559..02086f9 100644 --- a/src/treedb/mod.rs +++ b/src/treedb/mod.rs @@ -364,7 +364,7 @@ impl Tree { key: K, mut f: F, ) -> Option { - let old_value = self.remove(&key); + let old_value = self.get(&key).map(|v| v.to_owned()); let new_value = f(old_value); self.log(&key, new_value.as_ref()); if let Some(new_value) = new_value {