[librsvg/librsvg-2.50] Simplify two functions that deal with attributes
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/librsvg-2.50] Simplify two functions that deal with attributes
- Date: Fri, 2 Oct 2020 19:24:35 +0000 (UTC)
commit 93191557a3d8dbcd1e81db35ff225d84b7b5d3ec
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Sep 7 16:48:08 2020 -0500
Simplify two functions that deal with attributes
rsvg_internals/src/element.rs | 30 ++++++++++++------------------
1 file changed, 12 insertions(+), 18 deletions(-)
---
diff --git a/rsvg_internals/src/element.rs b/rsvg_internals/src/element.rs
index c5165a0f..9f07d394 100644
--- a/rsvg_internals/src/element.rs
+++ b/rsvg_internals/src/element.rs
@@ -188,31 +188,25 @@ impl<T: SetAttributes + Draw> ElementInner<T> {
}
fn save_style_attribute(&mut self) {
- let attrs = self.attributes.borrow();
-
- let result = attrs
- .iter()
- .find(|(attr, _)| attr.expanded() == expanded_name!("", "style"))
- .map(|(_, value)| value);
- if let Some(value) = result {
- self.style_attr.push_str(value);
- }
+ self.style_attr.push_str(
+ self.attributes
+ .borrow()
+ .iter()
+ .find(|(attr, _)| attr.expanded() == expanded_name!("", "style"))
+ .map(|(_, value)| value)
+ .unwrap_or("")
+ );
}
fn set_transform_attribute(&mut self) -> Result<(), ElementError> {
- let pair = self.attributes
+ self.transform = self.attributes
.borrow()
.iter()
.find(|(attr, _)| attr.expanded() == expanded_name!("", "transform"))
.map(|(attr, value)| {
- (attr.clone(), value.to_string())
- });
-
- if let Some((attr, value)) = pair {
- Transform::parse_str(&value).attribute(attr).map(|affine| {
- self.transform = affine;
- })?;
- }
+ Transform::parse_str(value).attribute(attr)
+ })
+ .unwrap_or_else(|| Ok(Transform::default()))?;
Ok(())
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]