From ce047e46f8b4afa39fa4bbb35310d7ba36ec32e7 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 3 Jan 2026 15:07:21 -0800 Subject: [PATCH] cleanup --- rust/pspp/src/spv/read/legacy_xml.rs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) 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), -- 2.30.2