[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:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user