[librsvg: 2/4] Replace uses of node.foreach_child() with iteration
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 2/4] Replace uses of node.foreach_child() with iteration
- Date: Thu, 15 Mar 2018 16:54:37 +0000 (UTC)
commit d8250c3944ea4a44d9faff1b7795d2cffd8dd740
Author: Ivan Molodetskikh <yalterz gmail com>
Date: Thu Mar 15 09:36:34 2018 +0300
Replace uses of node.foreach_child() with iteration
rsvg_internals/src/gradient.rs | 10 ++++------
rsvg_internals/src/node.rs | 10 ++++------
rsvg_internals/src/structure.rs | 8 +++-----
3 files changed, 11 insertions(+), 17 deletions(-)
---
diff --git a/rsvg_internals/src/gradient.rs b/rsvg_internals/src/gradient.rs
index 17fc2275..b394e0e3 100644
--- a/rsvg_internals/src/gradient.rs
+++ b/rsvg_internals/src/gradient.rs
@@ -308,21 +308,19 @@ impl Gradient {
|| node.get_type() == NodeType::RadialGradient
);
- node.foreach_child(|child| {
+ for child in node.children() {
if child.get_type() != NodeType::Stop {
- return true; // just ignore this child; we are only interested in gradient stops
+ continue; // just ignore this child; we are only interested in gradient stops
}
if child.get_result().is_err() {
- return false; // don't add any more stops
+ break; // don't add any more stops
}
child.with_impl(|stop: &NodeStop| {
self.add_color_stop(stop.get_offset(), stop.get_rgba());
});
-
- true
- });
+ }
}
fn add_color_stop(&mut self, offset: f64, rgba: u32) {
diff --git a/rsvg_internals/src/node.rs b/rsvg_internals/src/node.rs
index 95ae8984..e6d9cae1 100644
--- a/rsvg_internals/src/node.rs
+++ b/rsvg_internals/src/node.rs
@@ -219,15 +219,13 @@ impl Node {
drawing_ctx::push_discrete_layer(draw_ctx);
}
- self.foreach_child(|child| {
+ for child in self.children() {
let boxed_child = box_node(child.clone());
drawing_ctx::draw_node_from_stack(draw_ctx, boxed_child, 0);
rsvg_node_unref(boxed_child);
-
- true
- });
+ }
if dominate != -1 {
drawing_ctx::pop_discrete_layer(draw_ctx);
@@ -238,8 +236,8 @@ impl Node {
where
F: FnMut(Rc<Node>) -> bool,
{
- for c in &*self.children.borrow() {
- let next = f(c.clone());
+ for child in self.children() {
+ let next = f(child);
if !next {
break;
}
diff --git a/rsvg_internals/src/structure.rs b/rsvg_internals/src/structure.rs
index fa26c82a..55d28f68 100644
--- a/rsvg_internals/src/structure.rs
+++ b/rsvg_internals/src/structure.rs
@@ -84,7 +84,7 @@ impl NodeTrait for NodeSwitch {
drawing_ctx::push_discrete_layer(draw_ctx);
- node.foreach_child(|child| {
+ for child in node.children() {
if drawing_ctx::state_get_cond_true(child.get_state()) {
let boxed_child = box_node(child.clone());
@@ -92,11 +92,9 @@ impl NodeTrait for NodeSwitch {
rsvg_node_unref(boxed_child);
- false // just draw this child
- } else {
- true
+ break; // just draw this child
}
- });
+ }
drawing_ctx::pop_discrete_layer(draw_ctx);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]