Gitweb links:
...log
http://git.netsurf-browser.org/libdom.git/shortlog/140a849dc70bf1d9270bee...
...commit
http://git.netsurf-browser.org/libdom.git/commit/140a849dc70bf1d9270bee81...
...tree
http://git.netsurf-browser.org/libdom.git/tree/140a849dc70bf1d9270bee8165...
The branch, master has been updated
via 140a849dc70bf1d9270bee8165bc0f098e097314 (commit)
via d49ce7364ef8d6b577a077c9883f251acb5a3f99 (commit)
from 2e707ef487896b68494ecb07f0047be164e4ae8e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/libdom.git/commit/?id=140a849dc70bf1d9270b...
commit 140a849dc70bf1d9270bee8165bc0f098e097314
Merge: 2e707ef d49ce73
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Merge branch 'tlsa/faster-strings'
-----------------------------------------------------------------------
Summary of changes:
src/core/string.c | 68 +++++++++++++++++++++++++++++++++++------------------
1 file changed, 45 insertions(+), 23 deletions(-)
diff --git a/src/core/string.c b/src/core/string.c
index 9af2e74..1f0fdd5 100644
--- a/src/core/string.c
+++ b/src/core/string.c
@@ -978,36 +978,58 @@ dom_string_toupper(dom_string *source, bool ascii_only, dom_string
**upper)
dom_exception
dom_string_tolower(dom_string *source, bool ascii_only, dom_string **lower)
{
- const uint8_t *orig_s = (const uint8_t *) dom_string_data(source);
- const size_t nbytes = dom_string_byte_length(source);
- uint8_t *copy_s;
- size_t index = 0;
- dom_exception exc;
-
+ dom_string_internal *isource = (dom_string_internal *)source;
+ dom_exception exc = DOM_NO_ERR;
+
if (ascii_only == false)
return DOM_NOT_SUPPORTED_ERR;
-
- copy_s = malloc(nbytes);
- if (copy_s == NULL)
- return DOM_NO_MEM_ERR;
- memcpy(copy_s, orig_s, nbytes);
-
- while (index < nbytes) {
- if (orig_s[index] >= 'A' && orig_s[index] <= 'Z') {
- copy_s[index] += 'a' - 'A';
- }
- index++;
- }
-
- if (((dom_string_internal*)source)->type == DOM_STRING_CDATA) {
+ if (isource->type == DOM_STRING_CDATA) {
+ const uint8_t *orig_s = (const uint8_t *)
+ dom_string_data(source);
+ const size_t nbytes = dom_string_byte_length(source);
+ size_t index = 0;
+ uint8_t *copy_s;
+
+ copy_s = malloc(nbytes);
+ if (copy_s == NULL)
+ return DOM_NO_MEM_ERR;
+ memcpy(copy_s, orig_s, nbytes);
+
+ while (index < nbytes) {
+ if (orig_s[index] >= 'A' && orig_s[index] <= 'Z') {
+ copy_s[index] += 'a' - 'A';
+ }
+
+ index++;
+ }
exc = dom_string_create(copy_s, nbytes, lower);
+
+ free(copy_s);
} else {
- exc = dom_string_create_interned(copy_s, nbytes, lower);
+ bool equal;
+ lwc_error err;
+ lwc_string *l;
+
+ err = lwc_string_tolower(isource->data.intern, &l);
+ if (err != lwc_error_ok) {
+ return DOM_NO_MEM_ERR;
+ }
+
+ if (lwc_string_isequal(isource->data.intern, l, &equal) ==
+ lwc_error_ok && equal == true) {
+ /* String is already lower case. */
+ *lower = dom_string_ref(source);
+ } else {
+ /* TODO: create dom_string wrapper around existing
+ * lwc string. */
+ exc = dom_string_create_interned(
+ (const uint8_t *)lwc_string_data(l),
+ lwc_string_length(l), lower);
+ }
+ lwc_string_unref(l);
}
- free(copy_s);
-
return exc;
}
--
Document Object Model library