aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2006-02-07 22:44:47 +0800
committerChristian Persch <chpe@src.gnome.org>2006-02-07 22:44:47 +0800
commit00c4fe8b478f51708e98cb258543b14498b883c0 (patch)
tree84a71b74c026accf2053ff5e865c63f7183e77ee
parent606ece5007615a042b512a61463b4232a9e6f553 (diff)
downloadgsoc2013-epiphany-00c4fe8b478f51708e98cb258543b14498b883c0.tar
gsoc2013-epiphany-00c4fe8b478f51708e98cb258543b14498b883c0.tar.gz
gsoc2013-epiphany-00c4fe8b478f51708e98cb258543b14498b883c0.tar.bz2
gsoc2013-epiphany-00c4fe8b478f51708e98cb258543b14498b883c0.tar.lz
gsoc2013-epiphany-00c4fe8b478f51708e98cb258543b14498b883c0.tar.xz
gsoc2013-epiphany-00c4fe8b478f51708e98cb258543b14498b883c0.tar.zst
gsoc2013-epiphany-00c4fe8b478f51708e98cb258543b14498b883c0.zip
Save tons of g_type_from_name calls.
2006-02-07 Christian Persch <chpe@cvs.gnome.org> * lib/ephy-node.c: (ephy_node_new_from_xml): Save tons of g_type_from_name calls.
-rw-r--r--ChangeLog6
-rw-r--r--lib/ephy-node.c68
2 files changed, 44 insertions, 30 deletions
diff --git a/ChangeLog b/ChangeLog
index 3f67ab5ef..b957e58a3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-02-07 Christian Persch <chpe@cvs.gnome.org>
+
+ * lib/ephy-node.c: (ephy_node_new_from_xml):
+
+ Save tons of g_type_from_name calls.
+
2006-02-06 Christian Persch <chpe@cvs.gnome.org>
* src/ephy-main.c: (main):
diff --git a/lib/ephy-node.c b/lib/ephy-node.c
index 36bc2d22c..7da180d19 100644
--- a/lib/ephy-node.c
+++ b/lib/ephy-node.c
@@ -856,59 +856,67 @@ ephy_node_new_from_xml (EphyNodeDb *db, xmlNodePtr xml_node)
ephy_node_emit_signal (parent, EPHY_NODE_CHILD_ADDED, node);
}
} else if (strcmp ((const char *)xml_child->name, "property") == 0) {
- GType value_type;
GValue *value;
+ xmlChar *xmlType, *xmlValue;
int property_id;
xml = xmlGetProp (xml_child, (const xmlChar *)"id");
property_id = atoi ((const char *)xml);
xmlFree (xml);
- xml = xmlGetProp (xml_child, (const xmlChar *)"value_type");
- value_type = g_type_from_name ((const gchar *)xml);
- xmlFree (xml);
+ xmlType = xmlGetProp (xml_child, (const xmlChar *)"value_type");
+ xmlValue = xmlNodeGetContent (xml_child);
- xml = xmlNodeGetContent (xml_child);
value = g_new0 (GValue, 1);
- g_value_init (value, value_type);
- switch (value_type)
+ if (xmlStrEqual (xmlType, (const xmlChar *) "gchararray"))
{
- case G_TYPE_STRING:
- g_value_set_string (value, (const gchar *)xml);
- break;
- case G_TYPE_INT:
- g_value_set_int (value, atoi ((const char *)xml));
- break;
- case G_TYPE_BOOLEAN:
- g_value_set_boolean (value, atoi ((const char *)xml));
- break;
- case G_TYPE_LONG:
- g_value_set_long (value, atol ((const char *)xml));
- break;
- case G_TYPE_FLOAT:
- g_value_set_float (value, g_ascii_strtod ((const gchar *)xml, NULL));
- break;
- case G_TYPE_DOUBLE:
- g_value_set_double (value, g_ascii_strtod ((const gchar *)xml, NULL));
- break;
- case G_TYPE_POINTER:
+ g_value_init (value, G_TYPE_STRING);
+ g_value_set_string (value, (const gchar *)xmlValue);
+ }
+ else if (xmlStrEqual (xmlType, (const xmlChar *) "gint"))
+ {
+ g_value_init (value, G_TYPE_INT);
+ g_value_set_int (value, atoi ((const char *)xmlValue));
+ }
+ else if (xmlStrEqual (xmlType, (const xmlChar *) "gboolean"))
+ {
+ g_value_init (value, G_TYPE_BOOLEAN);
+ g_value_set_boolean (value, atoi ((const char *)xmlValue));
+ }
+ else if (xmlStrEqual (xmlType, (const xmlChar *) "glong"))
+ {
+ g_value_init (value, G_TYPE_LONG);
+ g_value_set_long (value, atol ((const char *)xmlValue));
+ }
+ else if (xmlStrEqual (xmlType, (const xmlChar *) "gfloat"))
+ {
+ g_value_init (value, G_TYPE_FLOAT);
+ g_value_set_float (value, g_ascii_strtod ((const gchar *)xmlValue, NULL));
+ }
+ else if (xmlStrEqual (xmlType, (const xmlChar *) "gdouble"))
+ {
+ g_value_init (value, G_TYPE_DOUBLE);
+ g_value_set_double (value, g_ascii_strtod ((const gchar *)xmlValue, NULL));
+ }
+ else if (xmlStrEqual (xmlType, (const xmlChar *) "gpointer"))
{
EphyNode *property_node;
- property_node = ephy_node_db_get_node_from_id (db, atol ((const char *)xml));
+ property_node = ephy_node_db_get_node_from_id (db, atol ((const char *)xmlValue));
g_value_set_pointer (value, property_node);
break;
}
- default:
+ else
+ {
g_assert_not_reached ();
- break;
}
real_set_property (node, property_id, value);
- xmlFree (xml);
+ xmlFree (xmlValue);
+ xmlFree (xmlType);
}
}