From: Ben Pfaff Date: Sat, 3 Jan 2026 23:07:21 +0000 (-0800) Subject: cleanup X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce047e46f8b4afa39fa4bbb35310d7ba36ec32e7;p=pspp cleanup --- diff --git a/rust/pspp/src/spv/read/legacy_xml.rs b/rust/pspp/src/spv/read/legacy_xml.rs index 8b49cf9882..b986aeecae 100644 --- a/rust/pspp/src/spv/read/legacy_xml.rs +++ b/rust/pspp/src/spv/read/legacy_xml.rs @@ -197,20 +197,15 @@ impl Visualization { data: IndexMap>>>, warn: &mut dyn FnMut(LegacyXmlWarning), ) -> BTreeMap<&str, Series> { - let mut variables: Vec<&dyn Variable> = Vec::new(); - for child in &self.children { - match child { - VisChild::SourceVariable(source_variable) => variables.push(source_variable), - VisChild::DerivedVariable(derived_variable) => variables.push(derived_variable), - _ => (), - } - } + let mut variables: Vec<&dyn Variable> = self + .children + .iter() + .filter_map(|child| child.variable()) + .collect(); let mut series = BTreeMap::<&str, Series>::new(); - while let n = variables.len() - && n > 0 - { + while !variables.is_empty() { + let n = variables.len(); variables.retain(|variable| !variable.decode(&data, &mut series, warn)); - if n == variables.len() { warn(LegacyXmlWarning::UnresolvedDependencies( variables @@ -763,6 +758,13 @@ enum VisChild { } impl VisChild { + fn variable(&self) -> Option<&dyn Variable> { + match self { + VisChild::SourceVariable(source_variable) => Some(source_variable), + VisChild::DerivedVariable(derived_variable) => Some(derived_variable), + _ => None, + } + } fn style(&self) -> Option<&Style> { match self { Self::Style(style) => Some(style),