[librsvg: 67/95] node_set_atts(): Parse attributes with the PHF



commit cf5c32224219b69051b00cda1e0e368904b32f5f
Author: Federico Mena Quintero <federico gnome org>
Date:   Wed Feb 21 11:39:47 2018 -0600

    node_set_atts(): Parse attributes with the PHF

 rsvg-base.c | 39 ++++++++++++++++++++++++++++-----------
 1 file changed, 28 insertions(+), 11 deletions(-)
---
diff --git a/rsvg-base.c b/rsvg-base.c
index 70bae2c9..6445863b 100644
--- a/rsvg-base.c
+++ b/rsvg-base.c
@@ -390,26 +390,43 @@ get_node_creator_for_element_name (const char *name)
 static void
 node_set_atts (RsvgNode * node, RsvgHandle *handle, const NodeCreator *creator, RsvgPropertyBag atts)
 {
-    const char *id;
-    const char *klazz;
+    RsvgPropertyBagIter *iter;
+    const char *key;
+    RsvgAttribute attr;
+    const char *value;
+
+    const char *id = NULL;
+    const char *klazz = NULL;
+
+    iter = rsvg_property_bag_iter_begin (atts);
+
+    while (rsvg_property_bag_iter_next (iter, &key, &attr, &value)) {
+        switch (attr) {
+        case RSVG_ATTRIBUTE_ID:
+            id = value;
+            rsvg_defs_register_node_by_id (handle->priv->defs, id, node);
+            break;
 
-    id = rsvg_property_bag_lookup (atts, "id");
-    if (id) {
-        rsvg_defs_register_node_by_id (handle->priv->defs, id, node);
+        case RSVG_ATTRIBUTE_CLASS:
+            if (creator->supports_class_attribute) {
+                klazz = value;
+            }
+            break;
+
+        default:
+            break;
+        }
     }
 
+    rsvg_property_bag_iter_end (iter);
+
     rsvg_node_set_atts (node, handle, atts);
 
     /* The "svg" node is special; it will load its id/class
      * attributes until the end, when rsvg_end_element() calls
-     * _rsvg_node_svg_apply_atts()
+     * rsvg_node_svg_apply_atts()
      */
     if (rsvg_node_get_type (node) != RSVG_NODE_TYPE_SVG) {
-        if (creator->supports_class_attribute)
-            klazz = rsvg_property_bag_lookup (atts, "class");
-        else
-            klazz = NULL;
-
         rsvg_parse_style_attrs (handle, node, creator->element_name, klazz, id, atts);
     }
 }


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