[librsvg: 1/4] Refactor set_style_attribute()




commit 91b516d79fa764785bf53b033b5fb0576285ba44
Author: Federico Mena Quintero <federico gnome org>
Date:   Fri Feb 12 10:26:55 2021 -0600

    Refactor set_style_attribute()

 src/element.rs | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/src/element.rs b/src/element.rs
index de16286d..666c0669 100644
--- a/src/element.rs
+++ b/src/element.rs
@@ -274,18 +274,20 @@ impl<T: SetAttributes + Draw> ElementInner<T> {
 
     /// Applies CSS styles from the saved value of the "style" attribute
     fn set_style_attribute(&mut self) {
-        if !self.style_attr.is_empty() {
+        let style = &self.style_attr;
+
+        if !style.is_empty() {
             if let Err(e) = self.specified_values.parse_style_declarations(
-                self.style_attr.as_str(),
+                style,
                 Origin::Author,
                 &mut self.important_styles,
             ) {
                 self.set_error(e);
             }
-
-            self.style_attr.clear();
-            self.style_attr.shrink_to_fit();
         }
+
+        self.style_attr.clear();
+        self.style_attr.shrink_to_fit();
     }
 
     fn set_error(&mut self, error: ElementError) {


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