chiark / gitweb /
Move fn load out of SimplePieceSpec into macro
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 15 Apr 2022 17:23:27 +0000 (18:23 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 15 Apr 2022 17:23:27 +0000 (18:23 +0100)
The only call site was in impl_PieceSpec_for_SimplePieceSpec.
Hoisting it there makes little codegen difference but seems more
natural.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/pieces.rs

index 9d9d7b78fb9403ebc89484e512b7a1adcb86da86..37297dc8a21fc510310cba6a5cd637ad160d9d9e 100644 (file)
@@ -309,13 +309,6 @@ impl<Desc, Outl:'static> GenericSimpleShape<Desc, Outl>
 #[typetag::serde(tag="type")]
 pub trait SimplePieceSpec: Debug {
   fn load_raw(&self) -> Result<(SimpleShape, &SimpleCommon), SpecError>;
-  #[throws(SpecError)]
-  fn load(&self) -> PieceSpecLoaded {
-    PieceSpecLoaded {
-      p: Box::new(self.load_raw()?.0),
-      occultable: None,
-    }
-  }
 }
 
 #[typetag::serde]
@@ -367,7 +360,10 @@ macro_rules! impl_PieceSpec_for_SimplePieceSpec { { $ty:ty } => {
     #[throws(SpecError)]
     fn load(&self, _: usize, _: &mut GPiece, _ig: &Instance, _:SpecDepth)
             -> PieceSpecLoaded {
-      SimplePieceSpec::load(self)?
+      PieceSpecLoaded {
+        p: Box::new(self.load_raw()?.0),
+        occultable: None,
+      }
     }
   }
 } }