From 2cb19855a3912291d7c60b473dde2cb2b0df4d5b Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 3 Jan 2026 11:43:47 -0800 Subject: [PATCH] cleanup --- rust/pspp/src/cli/show_spv.rs | 3 +-- rust/pspp/src/spv/read/legacy_xml.rs | 27 ++++++--------------------- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/rust/pspp/src/cli/show_spv.rs b/rust/pspp/src/cli/show_spv.rs index 95a87bff65..ce2bec2c30 100644 --- a/rust/pspp/src/cli/show_spv.rs +++ b/rust/pspp/src/cli/show_spv.rs @@ -202,7 +202,6 @@ impl ShowSpv { )); let mut pivot_table = PivotTable::new([(Axis3::Y, index), (Axis3::X, variables)]); - let formats = HashMap::new(); for (variable_index, (variable_name, values)) in data.values().flat_map(|map| map.iter()).enumerate() { @@ -213,7 +212,7 @@ impl ShowSpv { value: data_value.clone(), index: None, } - .as_format(&formats) + .as_format() .to_string() }), ); diff --git a/rust/pspp/src/spv/read/legacy_xml.rs b/rust/pspp/src/spv/read/legacy_xml.rs index ea27c1e00c..ded22a2026 100644 --- a/rust/pspp/src/spv/read/legacy_xml.rs +++ b/rust/pspp/src/spv/read/legacy_xml.rs @@ -68,19 +68,13 @@ impl DataValue { /// `format_map` and otherwise by interpreting it as a [Format] directly. /// /// This should probably be a method on some hypothetical FormatMap. - pub fn as_format( - &self, - format_map: &HashMap, - ) -> crate::format::Format { + pub fn as_format(&self) -> crate::format::Format { let f = match &self.value { Datum::Number(Some(number)) => *number as i64, Datum::Number(None) => 0, Datum::String(s) => s.parse().unwrap_or_default(), }; - match format_map.get(&f) { - Some(format) => *format, - None => decode_format(f as u32, &mut |_| () /*XXX*/), - } + decode_format(f as u32, &mut |_| () /*XXX*/) } /// Returns this data value interpreted using `format`. @@ -438,7 +432,7 @@ impl Visualization { let mut data = HashMap::new(); let mut coords = Vec::with_capacity(dims.len()); - let (cell_formats, format_map) = graph.interval.labeling.decode_format_map(&series); + let cell_formats = graph.interval.labeling.decode_format_map(&series); 'outer: for (i, cell) in cell.values.iter().enumerate() { coords.clear(); for dim in dims { @@ -458,7 +452,7 @@ impl Visualization { let format = if let Some(cell_formats) = &cell_formats && let Some(value) = cell_formats.values.get(i) { - value.as_format(&format_map) + value.as_format() } else { F40_2 }; @@ -1934,23 +1928,14 @@ struct Labeling { } impl Labeling { - fn decode_format_map<'a>( - &self, - series: &'a BTreeMap<&str, Series>, - ) -> (Option<&'a Series>, HashMap) { - let mut map = HashMap::new(); + fn decode_format_map<'a>(&self, series: &'a BTreeMap<&str, Series>) -> Option<&'a Series> { let mut cell_format = None; for child in &self.children { if let LabelingChild::Formatting(formatting) = child { cell_format = series.get(formatting.variable.as_str()); - for mapping in &formatting.mappings { - if let Some(format) = &mapping.format { - map.insert(mapping.from, format.decode()); - } - } } } - (cell_format, map) + cell_format } } -- 2.30.2