diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2011-10-31 21:27:11 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2011-10-31 21:27:11 +0000 |
commit | c6f13db85878aeeaa7efd3894db88fe0d8a78168 (patch) | |
tree | f9a7a5dc824dabdd47a0d6a25313600f86e8c2cb /utils | |
parent | f980e6015f90e0bcb60459a8f490e1e2a6195d71 (diff) | |
download | netsurf-c6f13db85878aeeaa7efd3894db88fe0d8a78168.tar.gz netsurf-c6f13db85878aeeaa7efd3894db88fe0d8a78168.tar.bz2 |
Don't need to generate string from scratch in nsurl_defragment, just copy.
svn path=/trunk/netsurf/; revision=13103
Diffstat (limited to 'utils')
-rw-r--r-- | utils/nsurl.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/utils/nsurl.c b/utils/nsurl.c index 862797627..9978ded15 100644 --- a/utils/nsurl.c +++ b/utils/nsurl.c @@ -1736,13 +1736,14 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined) /* exported interface, documented in nsurl.h */ nserror nsurl_defragment(const nsurl *url, nsurl **no_frag) { - struct nsurl_component_lengths str_len = { 0, 0, 0, 0, 0, 0, 0, 0 }; - enum nsurl_string_flags str_flags = 0; size_t length; + char *pos; - /* Get the string length and find which parts of url are present */ - nsurl__get_string_data(&(url->components), NSURL_COMPLETE, &length, - &str_len, &str_flags); + /* Find the change in length from url to new_url */ + length = url->length; + if (url->components.fragment != NULL) { + length -= 1 + lwc_string_length(url->components.fragment); + } /* Create NetSurf URL object */ *no_frag = malloc(sizeof(nsurl) + length + 1); /* Add 1 for \0 */ @@ -1770,8 +1771,10 @@ nserror nsurl_defragment(const nsurl *url, nsurl **no_frag) (*no_frag)->length = length; /* Fill out the url string */ - nsurl_get_string(&((*no_frag)->components), (*no_frag)->string, - &str_len, str_flags); + pos = (*no_frag)->string; + memcpy(pos, url->string, length); + pos += length; + *pos = '\0'; /* Give the URL a reference */ (*no_frag)->count = 1; |