From 399b0d94b0b3f8e87a1663d09b0321541801f79c Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Thu, 5 Jul 2012 09:34:58 +0100 Subject: DOMDocument: Memoize the empty string --- src/core/document.c | 10 ++++++++++ src/core/document.h | 1 + 2 files changed, 11 insertions(+) (limited to 'src/core') diff --git a/src/core/document.c b/src/core/document.c index 5a286fc..c43f0bc 100644 --- a/src/core/document.c +++ b/src/core/document.c @@ -140,6 +140,16 @@ dom_exception _dom_document_initialise(dom_document *doc, if (err != DOM_NO_ERR) return err; + /* Intern the empty string. The use of a space in the constant + * is to prevent the compiler warning about an empty string. + */ + err = dom_string_create_interned((const uint8_t *) ' ', 0, + &doc->_memo_empty); + if (err != DOM_NO_ERR) { + dom_string_unref(doc->class_string); + return err; + } + /* We should not pass a NULL when all things hook up */ return _dom_document_event_internal_initialise(doc, &doc->dei, daf); } diff --git a/src/core/document.h b/src/core/document.h index a2b1801..6cf1f91 100644 --- a/src/core/document.h +++ b/src/core/document.h @@ -58,6 +58,7 @@ struct dom_document { /**< The DocumentEvent interface */ dom_document_quirks_mode quirks; /**< Document is in quirks mode */ + dom_string *_memo_empty; /**< The string ''. */ }; /* Create a DOM document */ -- cgit v1.2.3