summaryrefslogtreecommitdiff
path: root/content/url_store.c
diff options
context:
space:
mode:
authorRichard Wilson <rjw@netsurf-browser.org>2006-01-02 23:03:07 +0000
committerRichard Wilson <rjw@netsurf-browser.org>2006-01-02 23:03:07 +0000
commite68f319778277b34a4ade12a4c003b81c1b6c5a0 (patch)
tree05f6ba2b72e69e433153d8d44daf7cea97276109 /content/url_store.c
parent3403027d911f06497d037c6e754f69e90681af59 (diff)
downloadnetsurf-e68f319778277b34a4ade12a4c003b81c1b6c5a0.tar.gz
netsurf-e68f319778277b34a4ade12a4c003b81c1b6c5a0.tar.bz2
[project @ 2006-01-02 23:03:07 by rjw]
Quickly match repeated hostname calls. svn path=/import/netsurf/; revision=1968
Diffstat (limited to 'content/url_store.c')
-rw-r--r--content/url_store.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/content/url_store.c b/content/url_store.c
index 451027377..066607671 100644
--- a/content/url_store.c
+++ b/content/url_store.c
@@ -36,6 +36,7 @@ static struct hostname_data *url_store_match_hostname(const char *url,
struct hostname_data *previous);
static char *url_store_match_scheme = NULL;
+static struct hostname_data *last_hostname_found = NULL;
/**
* Returns the hostname data for the specified URL. If no hostname
@@ -49,26 +50,35 @@ struct hostname_data *url_store_find_hostname(const char *url)
struct hostname_data *search;
struct hostname_data *result;
url_func_result res;
- char *hostname;
+ char *hostname = NULL;
int hostname_length;
int compare;
int fast_exit_counter = ITERATIONS_BEFORE_TEST;
assert(url);
+ /* try to match the last hostname for http:// */
+ if ((last_hostname_found) &&
+ (!strncmp("http://", url, 7)) &&
+ (!strncmp(last_hostname_found->hostname, url + 7,
+ last_hostname_found->hostname_length))) {
+ return last_hostname_found;
+ }
+
+ /* no match found, fallback */
res = url_host(url, &hostname);
switch (res) {
- case URL_FUNC_OK:
- break;
- case URL_FUNC_NOMEM:
- return NULL;
- case URL_FUNC_FAILED:
- hostname = strdup("file:/"); /* for 'file:/' */
- if (!hostname)
+ case URL_FUNC_OK:
+ break;
+ case URL_FUNC_NOMEM:
return NULL;
- break;
- default:
- assert(0);
+ case URL_FUNC_FAILED:
+ hostname = strdup("file:/"); /* for 'file:/' */
+ if (!hostname)
+ return NULL;
+ break;
+ default:
+ assert(0);
}
hostname_length = strlen(hostname);
@@ -79,6 +89,7 @@ struct hostname_data *url_store_find_hostname(const char *url)
compare = strcmp(hostname, search->hostname);
if (compare == 0) {
free(hostname);
+ last_hostname_found = search;
return search;
} else if (compare < 0)
break;
@@ -99,6 +110,7 @@ struct hostname_data *url_store_find_hostname(const char *url)
result->url = 0;
result->previous = 0;
result->next = 0;
+ last_hostname_found = result;
/* simple case: no current hostnames */
if (!url_store_hostnames) {