From bd1db30530d492fa13c8d1401d043df41f86e337 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 3 Jan 2026 09:27:27 -0800 Subject: [PATCH] cleanup --- rust/pspp/src/spv/read/legacy_xml.rs | 32 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/rust/pspp/src/spv/read/legacy_xml.rs b/rust/pspp/src/spv/read/legacy_xml.rs index b953dcd402..790726042a 100644 --- a/rust/pspp/src/spv/read/legacy_xml.rs +++ b/rust/pspp/src/spv/read/legacy_xml.rs @@ -80,23 +80,17 @@ impl Map { &mut self, format: &Option, string_format: &Option, - ) -> (crate::format::Format, Vec) { - let (format, affixes, relabels, try_strings_as_numbers) = if let Some(format) = &format { + ) -> crate::format::Format { + let (format, relabels, try_strings_as_numbers) = if let Some(format) = &format { ( Some(format.decode()), - format.affixes.clone(), format.relabels.as_slice(), format.try_strings_as_numbers.unwrap_or_default(), ) } else if let Some(string_format) = &string_format { - ( - None, - string_format.affixes.clone(), - string_format.relabels.as_slice(), - false, - ) + (None, string_format.relabels.as_slice(), false) } else { - (None, Vec::new(), [].as_slice(), false) + (None, [].as_slice(), false) }; for relabel in relabels { let value = if try_strings_as_numbers && let Ok(to) = relabel.to.trim().parse::() { @@ -115,7 +109,7 @@ impl Map { }; self.0.insert(OrderedFloat(relabel.from), value); } - (format.unwrap_or(F8_0), affixes) + format.unwrap_or(F8_0) } fn apply(&self, data: &mut Vec) { @@ -847,6 +841,15 @@ struct SourceVariable { } impl SourceVariable { + fn affixes(&self) -> &[Affix] { + if let Some(format) = &self.format { + &format.affixes + } else if let Some(string_format) = &self.string_format { + &string_format.affixes + } else { + &[] + } + } fn decode<'a>( &'a self, data: &IndexMap>>, @@ -866,13 +869,10 @@ impl SourceVariable { { values.as_slice() } else { - /* - XXX warn - */ &[] }; let mut map = Map::new(); - let (format, affixes) = map.remap_formats(&self.format, &self.string_format); + let format = map.remap_formats(&self.format, &self.string_format); let mut data = Vec::from(data); if !map.0.is_empty() { map.apply(&mut data); @@ -882,7 +882,7 @@ impl SourceVariable { series.insert( &self.id, Series::new(self.id.clone(), data, map) - .with_affixes(affixes) + .with_affixes(Vec::from(self.affixes())) .with_label(self.label.clone()), ); true -- 2.30.2