From e5ce09545be980faaf500c778203dc2a9cefa4da Mon Sep 17 00:00:00 2001 From: Lee Smet Date: Wed, 17 Jul 2024 09:58:18 +0200 Subject: [PATCH] Manually implement absorb_second in RouterInner This allows us to avoid a clone on the routelist Arc. Signed-off-by: Lee Smet --- mycelium/src/routing_table.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/mycelium/src/routing_table.rs b/mycelium/src/routing_table.rs index 1c1c6bf..9a00c2f 100644 --- a/mycelium/src/routing_table.rs +++ b/mycelium/src/routing_table.rs @@ -637,6 +637,22 @@ impl left_right::Absorb for RoutingTableInner { self.table.insert(k, ss, v.clone()); } } + + fn absorb_second(&mut self, operation: RoutingTableOplogEntry, _: &Self) { + match operation { + RoutingTableOplogEntry::Upsert(subnet, list) => { + self.table.insert( + expect_ipv6(subnet.address()), + subnet.prefix_len().into(), + list, + ); + } + RoutingTableOplogEntry::Delete(subnet) => { + self.table + .remove(expect_ipv6(subnet.address()), subnet.prefix_len().into()); + } + } + } } impl Drop for RoutingTable {