From 5869107e6d28503ad01be3071667737b60fcb559 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Mon, 26 Mar 2012 17:57:29 +0000 Subject: Use HTMLDocument's memoised 'id' string, decimating cost of _dom_html_element_get_id svn path=/trunk/libdom/; revision=13724 --- src/html/html_element.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/html/html_element.c') diff --git a/src/html/html_element.c b/src/html/html_element.c index ffa7db9..4d43205 100644 --- a/src/html/html_element.c +++ b/src/html/html_element.c @@ -106,19 +106,19 @@ dom_exception _dom_html_element_copy(dom_node_internal *old, dom_exception _dom_html_element_get_id(dom_html_element *element, dom_string **id) { - dom_exception ret; - dom_string *idstr; - - ret = dom_string_create_interned((const uint8_t *) "id", SLEN("id"), - &idstr); - if (ret != DOM_NO_ERR) - return ret; - - ret = dom_element_get_attribute(element, idstr, id); - - dom_string_unref(idstr); - - return ret; + dom_exception ret; + dom_string *_memo_id; + + /* Because we're an HTML element, our document is always + * an HTML document, so we can get its memoised id string + */ + _memo_id = + ((struct dom_html_document *) + ((struct dom_node_internal *)element)->owner)->_memo_id; + + ret = dom_element_get_attribute(element, _memo_id, id); + + return ret; } dom_exception _dom_html_element_set_id(dom_html_element *element, -- cgit v1.2.3