fix collect child paths in store (#5069)
This commit is contained in:
1 parent
810321e053
commit
46b1639ddf
1 file changed
+14
-7
@@ -54,8 +54,10 @@ impl SelectorNode {
|
|||||||
/// This is used to mark nodes dirty recursively when a Store is written to.
|
/// This is used to mark nodes dirty recursively when a Store is written to.
|
||||||
fn paths_under(&self, current_path: &[PathKey], paths: &mut Vec<Box<[PathKey]>>) {
|
fn paths_under(&self, current_path: &[PathKey], paths: &mut Vec<Box<[PathKey]>>) {
|
||||||
paths.push(current_path.into());
|
paths.push(current_path.into());
|
||||||
for child in self.root.values() {
|
for (i, child) in self.root.iter() {
|
||||||
child.paths_under(current_path, paths);
|
let mut child_path: Vec<PathKey> = current_path.into();
|
||||||
|
child_path.push(*i);
|
||||||
|
child.paths_under(&child_path, paths);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +78,9 @@ impl SelectorNode {
|
|||||||
// Mark the nodes before the index as dirty
|
// Mark the nodes before the index as dirty
|
||||||
for (i, child) in node.root.iter() {
|
for (i, child) in node.root.iter() {
|
||||||
if *i as usize >= index {
|
if *i as usize >= index {
|
||||||
child.paths_under(path, paths);
|
let mut child_path: Vec<PathKey> = path.into();
|
||||||
|
child_path.push(*i);
|
||||||
|
child.paths_under(&child_path, paths);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -227,10 +231,13 @@ impl StoreSubscriptions {
|
|||||||
/// Mark the node and all its children as dirty
|
/// Mark the node and all its children as dirty
|
||||||
pub(crate) fn mark_dirty(&self, key: &[PathKey]) {
|
pub(crate) fn mark_dirty(&self, key: &[PathKey]) {
|
||||||
let paths = {
|
let paths = {
|
||||||
let read = self.inner.read();
|
let read = &self.inner.read_unchecked();
|
||||||
let mut nodes = Vec::new();
|
let Some(node) = read.root.get(key) else {
|
||||||
read.root.paths_under(key, &mut nodes);
|
return;
|
||||||
nodes
|
};
|
||||||
|
let mut paths = Vec::new();
|
||||||
|
node.paths_under(key, &mut paths);
|
||||||
|
paths
|
||||||
};
|
};
|
||||||
for path in paths {
|
for path in paths {
|
||||||
self.mark_dirty_shallow(&path);
|
self.mark_dirty_shallow(&path);
|
||||||
|
|||||||
Reference in new issue
Block a user