diff options
author | Daniel Silverstone <dsilvers@netsurf-browser.org> | 2012-03-26 17:57:29 +0000 |
---|---|---|
committer | Daniel Silverstone <dsilvers@netsurf-browser.org> | 2012-03-26 17:57:29 +0000 |
commit | 73c87c6681edc1a1e53a6e30b350e22844c6cb12 (patch) | |
tree | 659cc999416c2269b2f5e7eeb0a8febf230afc07 /src/html | |
parent | a03f470334566315bbd0a57dd53406f7738856ce (diff) | |
download | libdom-73c87c6681edc1a1e53a6e30b350e22844c6cb12.tar.gz libdom-73c87c6681edc1a1e53a6e30b350e22844c6cb12.tar.bz2 |
Use HTMLDocument's memoised 'id' string, decimating cost of _dom_html_element_get_id
svn path=/trunk/libdom/; revision=13724
Diffstat (limited to 'src/html')
-rw-r--r-- | src/html/html_element.c | 26 |
1 files changed, 13 insertions, 13 deletions
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, |