[librsvg] Simplify the code flow in rsvg_characters_impl()



commit 12c34a83c860b911979e4d6ff550edba731fd549
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Dec 5 16:18:59 2017 -0600

    Simplify the code flow in rsvg_characters_impl()

 rsvg-base.c |   25 ++++++++++---------------
 1 files changed, 10 insertions(+), 15 deletions(-)
---
diff --git a/rsvg-base.c b/rsvg-base.c
index 86043af..a845553 100644
--- a/rsvg-base.c
+++ b/rsvg-base.c
@@ -966,7 +966,7 @@ find_last_chars_node (RsvgNode *node, gpointer data)
 static void
 rsvg_characters_impl (RsvgHandle * ctx, const xmlChar * ch, gssize len)
 {
-    RsvgNode *node;
+    RsvgNode *node = NULL;
 
     if (!ch || !len)
         return;
@@ -976,28 +976,23 @@ rsvg_characters_impl (RsvgHandle * ctx, const xmlChar * ch, gssize len)
         if (type == RSVG_NODE_TYPE_TSPAN || type == RSVG_NODE_TYPE_TEXT) {
             /* find the last CHARS node in the text or tspan node, so that we
                can coalesce the text, and thus avoid screwing up the Pango layouts */
-            node = NULL;
             rsvg_node_foreach_child (ctx->priv->currentnode,
                                      find_last_chars_node,
                                      &node);
-
-            if (node) {
-                g_assert (rsvg_node_get_type (node) == RSVG_NODE_TYPE_CHARS);
-                rsvg_node_chars_append (node, (const char *) ch, len);
-
-                node = rsvg_node_unref (node);
-                return;
-            }
         }
     }
 
-    node = rsvg_new_node_chars (ctx->priv->currentnode);
-    rsvg_node_chars_append (node, (const char *) ch, len);
+    if (!node) {
+        node = rsvg_new_node_chars (ctx->priv->currentnode);
+        add_node_to_handle (ctx, node);
 
-    add_node_to_handle (ctx, node);
+        if (ctx->priv->currentnode)
+            rsvg_node_add_child (ctx->priv->currentnode, node);
+    } else {
+        g_assert (rsvg_node_get_type (node) == RSVG_NODE_TYPE_CHARS);
+    }
 
-    if (ctx->priv->currentnode)
-        rsvg_node_add_child (ctx->priv->currentnode, node);
+    rsvg_node_chars_append (node, (const char *) ch, len);
 
     node = rsvg_node_unref (node);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]