Skip to content

Commit

Permalink
Remove unused argument
Browse files Browse the repository at this point in the history
  • Loading branch information
sile committed Dec 2, 2023
1 parent d130ccf commit 0a249b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
17 changes: 6 additions & 11 deletions src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,18 +484,15 @@ impl<V> Node<V> {
pub(crate) fn get_prefix_node<K: ?Sized + BorrowedBytes>(
&self,
key: &K,
offset: usize,
) -> Option<(usize, &Self)> {
let (next, common_prefix_len) = key.strip_common_prefix_and_len(self.label());
if next.is_empty() {
Some((common_prefix_len, self)) // TODO: return offset?
Some((common_prefix_len, self))
} else if common_prefix_len == self.label().len() {
let offset = offset + common_prefix_len;
self.child()
.and_then(|child| child.get_prefix_node(next, offset))
self.child().and_then(|child| child.get_prefix_node(next))
} else if common_prefix_len == 0 && key.cmp_first_item(self.label()).is_ge() {
self.sibling()
.and_then(|sibling| sibling.get_prefix_node(next, offset))
.and_then(|sibling| sibling.get_prefix_node(next))
} else {
None
}
Expand All @@ -504,18 +501,16 @@ impl<V> Node<V> {
pub(crate) fn get_prefix_node_mut<K: ?Sized + BorrowedBytes>(
&mut self,
key: &K,
offset: usize,
) -> Option<(usize, &mut Self)> {
let (next, common_prefix_len) = key.strip_common_prefix_and_len(self.label());
if next.is_empty() {
Some((common_prefix_len, self)) // TODO: return offset?
Some((common_prefix_len, self))
} else if common_prefix_len == self.label().len() {
let offset = offset + common_prefix_len;
self.child_mut()
.and_then(|child| child.get_prefix_node_mut(next, offset))
.and_then(|child| child.get_prefix_node_mut(next))
} else if common_prefix_len == 0 && key.cmp_first_item(self.label()).is_ge() {
self.sibling_mut()
.and_then(|sibling| sibling.get_prefix_node_mut(next, offset))
.and_then(|sibling| sibling.get_prefix_node_mut(next))
} else {
None
}
Expand Down
4 changes: 2 additions & 2 deletions src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl<V> PatriciaTree<V> {
&'a self,
prefix: &'b K,
) -> Option<(usize, Nodes<V>)> {
if let Some((common_prefix_len, node)) = self.root.get_prefix_node(prefix, 0) {
if let Some((common_prefix_len, node)) = self.root.get_prefix_node(prefix) {
let nodes = Nodes {
nodes: node.iter_descendant(),
label_lens: Vec::new(),
Expand All @@ -72,7 +72,7 @@ impl<V> PatriciaTree<V> {
&'a mut self,
prefix: &'b K,
) -> Option<(usize, NodesMut<V>)> {
if let Some((common_prefix_len, node)) = self.root.get_prefix_node_mut(prefix, 0) {
if let Some((common_prefix_len, node)) = self.root.get_prefix_node_mut(prefix) {
let nodes = NodesMut {
nodes: node.iter_descendant_mut(),
label_lens: Vec::new(),
Expand Down

0 comments on commit 0a249b6

Please sign in to comment.