Author: tlsa
Date: Mon Oct 31 16:27:11 2011
New Revision: 13103
URL:
http://source.netsurf-browser.org?rev=13103&view=rev
Log:
Don't need to generate string from scratch in nsurl_defragment, just copy.
Modified:
trunk/netsurf/utils/nsurl.c
Modified: trunk/netsurf/utils/nsurl.c
URL:
http://source.netsurf-browser.org/trunk/netsurf/utils/nsurl.c?rev=13103&a...
==============================================================================
--- trunk/netsurf/utils/nsurl.c (original)
+++ trunk/netsurf/utils/nsurl.c Mon Oct 31 16:27:11 2011
@@ -1736,13 +1736,14 @@
/* 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;
-
- /* 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);
+ char *pos;
+
+ /* 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 @@
(*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;