[librsvg/librsvg-2.46] xml: use is_empty and return early
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/librsvg-2.46] xml: use is_empty and return early
- Date: Tue, 15 Oct 2019 16:46:02 +0000 (UTC)
commit eeba2a051efb02b77ae943c538c012e74b472498
Author: Paolo Borelli <pborelli gnome org>
Date: Sun Oct 13 12:27:03 2019 +0200
xml: use is_empty and return early
rsvg_internals/src/xml.rs | 51 ++++++++++++++++++++++++-----------------------
1 file changed, 26 insertions(+), 25 deletions(-)
---
diff --git a/rsvg_internals/src/xml.rs b/rsvg_internals/src/xml.rs
index 31c367c2..d16b587d 100644
--- a/rsvg_internals/src/xml.rs
+++ b/rsvg_internals/src/xml.rs
@@ -347,33 +347,34 @@ impl XmlState {
}
fn element_creation_characters(&self, text: &str) {
- let mut current_node = self.inner.borrow().current_node.as_ref().unwrap().clone();
-
- if text.len() != 0 {
- // When the last child is a Chars node we can coalesce
- // the text and avoid screwing up the Pango layouts
- let chars_node = if let Some(child) = current_node
- .last_child()
- .filter(|c| c.borrow().get_type() == NodeType::Chars)
- {
- child
- } else {
- let child = RsvgNode::new(NodeData::new(
- NodeType::Chars,
- LocalName::from("rsvg-chars"),
- None,
- None,
- Box::new(NodeChars::new()),
- ));
-
- self.inner.borrow_mut().num_loaded_elements += 1;
- current_node.append(child.clone());
+ if text.is_empty() {
+ return;
+ }
- child
- };
+ // When the last child is a Chars node we can coalesce
+ // the text and avoid screwing up the Pango layouts
+ let mut current_node = self.inner.borrow().current_node.as_ref().unwrap().clone();
+ let chars_node = if let Some(child) = current_node
+ .last_child()
+ .filter(|c| c.borrow().get_type() == NodeType::Chars)
+ {
+ child
+ } else {
+ let child = RsvgNode::new(NodeData::new(
+ NodeType::Chars,
+ LocalName::from("rsvg-chars"),
+ None,
+ None,
+ Box::new(NodeChars::new()),
+ ));
+
+ self.inner.borrow_mut().num_loaded_elements += 1;
+ current_node.append(child.clone());
+
+ child
+ };
- chars_node.borrow().get_impl::<NodeChars>().append(text);
- }
+ chars_node.borrow().get_impl::<NodeChars>().append(text);
}
fn xinclude_start_element(&self, _name: &str, pbag: &PropertyBag) -> Context {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]