[librsvg: 21/45] add_color_stops_from_node(): Borrow the child node only once
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 21/45] add_color_stops_from_node(): Borrow the child node only once
- Date: Tue, 1 Oct 2019 15:08:42 +0000 (UTC)
commit 7a64dff9c7c37daf8f5759b48cd48b5831d2d7f5
Author: Federico Mena Quintero <federico gnome org>
Date: Fri Sep 27 15:43:14 2019 -0500
add_color_stops_from_node(): Borrow the child node only once
I'm not sure I like this form either...
rsvg_internals/src/gradient.rs | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/rsvg_internals/src/gradient.rs b/rsvg_internals/src/gradient.rs
index a07a2195..401e8b7c 100644
--- a/rsvg_internals/src/gradient.rs
+++ b/rsvg_internals/src/gradient.rs
@@ -218,15 +218,21 @@ impl UnresolvedCommon {
fn add_color_stops_from_node(&mut self, node: &RsvgNode) {
assert!(node.borrow().get_type() == NodeType::Gradient);
- for child in node
- .children()
- .filter(|child| child.borrow().get_type() == NodeType::Stop)
+ for child_node in node.children()
{
- if child.borrow().is_in_error() {
+ let child = child_node.borrow();
+
+ if child.get_type() != NodeType::Stop {
+ continue;
+ }
+
+ let stop = child.get_impl::<NodeStop>();
+
+ if child.is_in_error() {
rsvg_log!("(not using gradient stop {} because it is in error)", child);
} else {
- let offset = child.borrow().get_impl::<NodeStop>().get_offset();
- let cascaded = CascadedValues::new_from_node(&child);
+ let offset = stop.get_offset();
+ let cascaded = CascadedValues::new_from_node(&child_node);
let values = cascaded.get();
let rgba = match values.stop_color {
StopColor(cssparser::Color::CurrentColor) => values.color.0,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]