Compute the locale info only for elements that use systemLanguage
I was looking at some heap analysis from valgrind --tool=dhat
and noticed this from element.rs:
fn set_conditional_processing_attributes(
&mut self,
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> {
match attr.expanded() {
// ...
expanded_name!("", "systemLanguage") if cond => {
cond = SystemLanguage::from_attribute(value, &locale)
.map(|SystemLanguage(res)| res)?;
}
Note how the locale
is computed once for each element (set_conditional_processing_attributes
is called only once per element), but only used for those that have the systemlanguage
attribute. There are very few of these in practice! We should only compute the locale for those that have the attribute.