Remove WeakRuleNode::clone

MallocSizeOf for RuleTree should not keep around weak references in
case someone runs a GC meanwhile.
This commit is contained in:
Anthony Ramine 2020-04-16 15:56:09 +02:00
parent e06e164571
commit 37c70609f9

View file

@ -71,14 +71,14 @@ impl MallocSizeOf for RuleTree {
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
let mut n = 0; let mut n = 0;
let mut stack = SmallVec::<[_; 32]>::new(); let mut stack = SmallVec::<[_; 32]>::new();
stack.push(self.root.downgrade()); stack.push(self.root.clone());
while let Some(node) = stack.pop() { while let Some(node) = stack.pop() {
n += unsafe { ops.malloc_size_of(node.ptr()) }; n += unsafe { ops.malloc_size_of(node.ptr()) };
let children = unsafe { (*node.ptr()).children.read() }; let children = unsafe { (*node.ptr()).children.read() };
children.shallow_size_of(ops); children.shallow_size_of(ops);
for c in &*children { for c in &*children {
stack.push(c.clone()); stack.push(c.upgrade());
} }
} }
@ -335,7 +335,6 @@ impl RuleNode {
} }
} }
#[derive(Clone)]
pub(crate) struct WeakRuleNode { pub(crate) struct WeakRuleNode {
p: ptr::NonNull<RuleNode>, p: ptr::NonNull<RuleNode>,
} }