cleanup
authorBen Pfaff <blp@cs.stanford.edu>
Sat, 3 Jan 2026 17:27:27 +0000 (09:27 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Sat, 3 Jan 2026 17:27:27 +0000 (09:27 -0800)
rust/pspp/src/spv/read/legacy_xml.rs

index b953dcd4029fb03782c9cbb47e70fcd53b7213cc..790726042adf342b8e76e9b032f98300c063761d 100644 (file)
@@ -80,23 +80,17 @@ impl Map {
         &mut self,
         format: &Option<Format>,
         string_format: &Option<StringFormat>,
-    ) -> (crate::format::Format, Vec<Affix>) {
-        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::<f64>() {
@@ -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<DataValue>) {
@@ -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<String, IndexMap<String, Vec<DataValue>>>,
@@ -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