r13722 dsilvers - /trunk/libdom/src/core/attr.c

netsurf at semichrome.net netsurf at semichrome.net
Mon Mar 26 18:47:37 BST 2012


Author: dsilvers
Date: Mon Mar 26 12:47:37 2012
New Revision: 13722

URL: http://source.netsurf-browser.org?rev=13722&view=rev
Log:
When retrieving attribute values, if the attribute has a single child, said child is a text node, and has a value, then just ref that string and return it.

Modified:
    trunk/libdom/src/core/attr.c

Modified: trunk/libdom/src/core/attr.c
URL: http://source.netsurf-browser.org/trunk/libdom/src/core/attr.c?rev=13722&r1=13721&r2=13722&view=diff
==============================================================================
--- trunk/libdom/src/core/attr.c (original)
+++ trunk/libdom/src/core/attr.c Mon Mar 26 12:47:37 2012
@@ -445,7 +445,16 @@
 	struct dom_node_internal *c;
 	dom_string *value, *temp;
 	dom_exception err;
-
+        
+	/* Attempt to shortcut for a single text node child with value */
+	if ((a->first_child != NULL) && 
+	    (a->first_child == a->last_child) &&
+	    (a->first_child->type == DOM_TEXT_NODE) &&
+	    (a->first_child->value != NULL)) {
+		*result = dom_string_ref(a->first_child->value);
+		return DOM_NO_ERR;
+	}
+	
 	err = dom_string_create(NULL, 0, &value);
 	if (err != DOM_NO_ERR) {
 		return err;




More information about the netsurf-commits mailing list