[RadixTree] Optimize the Time Complexity of Node Retrieval Operation from O(n*m) to O(n) (#13334)

Signed-off-by: CLFutureX <chenyongqyl@163.com>
Co-authored-by: Zhiqiang Xie <xiezhq@stanford.edu>
This commit is contained in:
PiteXChen
2025-12-09 07:55:09 +08:00
committed by GitHub
parent 07404d7689
commit eac5b66485
4 changed files with 22 additions and 24 deletions

View File

@@ -730,10 +730,10 @@ class RadixCache(BasePrefixCache):
), f"{key=}, {self.get_child_key_fn(child.key)=}"
def _delete_leaf(self, node):
for k, v in node.parent.children.items():
if v == node:
break
del node.parent.children[k]
key = self.get_child_key_fn(node.key)
v = node.parent.children.pop(key, None)
assert v == node, f"parent does not have child key, {key}"
self.evictable_size_ -= len(node.key)
def _total_size_helper(self):