[librsvg: 10/16] Use a PropertyId::is_shorthand() function instead of special-casing Marker



commit beb35eb27a00e7713c64f6a48489ac432fb3f9b1
Author: Federico Mena Quintero <federico gnome org>
Date:   Wed Mar 25 13:22:19 2020 -0600

    Use a PropertyId::is_shorthand() function instead of special-casing Marker

 rsvg_internals/src/properties.rs | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/rsvg_internals/src/properties.rs b/rsvg_internals/src/properties.rs
index 1f85c7eb..43901d31 100644
--- a/rsvg_internals/src/properties.rs
+++ b/rsvg_internals/src/properties.rs
@@ -280,6 +280,15 @@ macro_rules! make_properties {
             UnsetProperty,
         }
 
+        impl PropertyId {
+            fn is_shorthand(self) -> bool {
+                match self {
+                    $(PropertyId::$short_name => true,)+
+                    _ => false,
+                }
+            }
+        }
+
         /// Embodies "which property is this" plus the property's value
         #[derive(Clone)]
         pub enum ParsedProperty {
@@ -394,10 +403,7 @@ impl SpecifiedValues {
 
     fn set_property(&mut self, prop: &ParsedProperty, replace: bool) {
         let id = prop.get_property_id();
-
-        if id == PropertyId::Marker {
-            unreachable!("should have processed shorthands earlier");
-        }
+        assert!(!id.is_shorthand());
 
         if let Some(index) = self.property_index(id) {
             if replace {
@@ -411,9 +417,7 @@ impl SpecifiedValues {
     }
 
     fn get_property(&self, id: PropertyId) -> ParsedProperty {
-        if id == PropertyId::Marker {
-            unreachable!("should have processed shorthands earlier");
-        }
+        assert!(!id.is_shorthand());
 
         if let Some(index) = self.property_index(id) {
             self.props[index].clone()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]