From d3dd4d1b4d52a616130e3ddbb4c6666a352f6a1d Mon Sep 17 00:00:00 2001 From: Jay Kickliter Date: Wed, 25 Sep 2024 16:35:07 -0600 Subject: [PATCH 1/2] remove out of data comment --- src/node.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/node.rs b/src/node.rs index 7542c3f..5db1c56 100644 --- a/src/node.rs +++ b/src/node.rs @@ -1,12 +1,5 @@ use crate::{compaction::Compactor, digits::Digits, Cell}; -// TODO: storing indices in nodes is not necessary, since the index -// can always be derived by the path through the tree to get to the -// node. That said, storing the index doesn't impose much lookup -// overhead. -// -// The benefit of storing indices is vastly simpler Cell+Value -// iteration of a tree. #[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[repr(align(64))] From 5369ab5e1475ee18e4d73835e32f38977fe18d8e Mon Sep 17 00:00:00 2001 From: Jay Kickliter Date: Wed, 25 Sep 2024 16:40:30 -0600 Subject: [PATCH 2/2] favor expect over commented unwraps --- src/cell.rs | 9 +++++++-- src/entry.rs | 3 +-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/cell.rs b/src/cell.rs index 7d84baa..e6dde73 100755 --- a/src/cell.rs +++ b/src/cell.rs @@ -212,8 +212,13 @@ impl Cell { #[inline] pub fn is_related_to(&self, other: &Self) -> bool { let common_res = std::cmp::min(self.res(), other.res()); - // Unwrap is fine. We already checked to the min common resolution. - self.to_parent(common_res).unwrap() == other.to_parent(common_res).unwrap() + let promoted_self = self + .to_parent(common_res) + .expect("we already checked to the min common resolution"); + let promoted_other = other + .to_parent(common_res) + .expect("we already checked to the min common resolution"); + promoted_self == promoted_other } } diff --git a/src/entry.rs b/src/entry.rs index 85a1ddc..33779c7 100644 --- a/src/entry.rs +++ b/src/entry.rs @@ -176,8 +176,7 @@ where }) => cell_value, Entry::Vacant(VacantEntry { target_cell, map }) => { map.insert(target_cell, Default::default()); - // We just inserted; unwrap is fine. - map.get_mut(target_cell).unwrap() + map.get_mut(target_cell).expect("we just inserted") } } }