[librsvg] (#594): Only compute locale info for elements that need it.



commit 056f8d227e6198b0590a64d0b0b6ab1abcfb90f7
Author: Federico Mena Quintero <federico gnome org>
Date:   Wed Apr 22 18:02:35 2020 -0500

    (#594): Only compute locale info for elements that need it.
    
    Fixes https://gitlab.gnome.org/GNOME/librsvg/-/issues/594

 rsvg_internals/src/element.rs | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/rsvg_internals/src/element.rs b/rsvg_internals/src/element.rs
index e807e531..7dd9aa65 100644
--- a/rsvg_internals/src/element.rs
+++ b/rsvg_internals/src/element.rs
@@ -174,7 +174,6 @@ impl<T: SetAttributes + Draw> ElementInner<T> {
         pbag: &PropertyBag<'_>,
     ) -> Result<(), ElementError> {
         let mut cond = self.cond;
-        let locale = locale_from_environment();
 
         for (attr, value) in pbag.iter() {
             let mut parse = || -> Result<_, ValueErrorKind> {
@@ -190,6 +189,13 @@ impl<T: SetAttributes + Draw> ElementInner<T> {
                     }
 
                     expanded_name!("", "systemLanguage") if cond => {
+                        // In reality this could be computed only once, at the beginning
+                        // of loading... maybe if we end up having a LoadContext again.
+                        //
+                        // (This call has a lot of memory churn internally with many
+                        // short-lived allocations.)
+                        let locale = locale_from_environment();
+
                         cond = SystemLanguage::from_attribute(value, &locale)
                             .map(|SystemLanguage(res)| res)?;
                     }


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