From 90d2c8c2127a91634722cf243cd492998a4c9148 Mon Sep 17 00:00:00 2001 From: "Rob Kendrick (humdrum)" Date: Mon, 20 May 2013 09:19:31 +0100 Subject: Use hash generated by nsurl rather than doing it ourselves --- content/urldb.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'content/urldb.c') diff --git a/content/urldb.c b/content/urldb.c index c52dc5b76..059c3c687 100644 --- a/content/urldb.c +++ b/content/urldb.c @@ -461,11 +461,6 @@ void urldb_load(const char *filename) (port ? ports : ""), s); - if (url_bloom != NULL) - bloom_insert_str(url_bloom, - url, - strlen(url)); - /* TODO: store URLs in pre-parsed state, and make * a nsurl_load to generate the nsurl more * swiftly. @@ -476,6 +471,11 @@ void urldb_load(const char *filename) die("Memory exhausted whilst loading " "URL file"); } + + if (url_bloom != NULL) { + uint32_t hash = nsurl_hash(nsurl); + bloom_insert_hash(url_bloom, hash); + } /* Copy and merge path/query strings */ if (nsurl_get(nsurl, NSURL_PATH | NSURL_QUERY, @@ -806,9 +806,10 @@ bool urldb_add_url(nsurl *url) if (url_bloom == NULL) url_bloom = bloom_create(BLOOM_SIZE); - if (url_bloom != NULL) - bloom_insert_str(url_bloom, nsurl_access(url), - nsurl_length(url)); + if (url_bloom != NULL) { + uint32_t hash = nsurl_hash(url); + bloom_insert_hash(url_bloom, hash); + } /* Copy and merge path/query strings */ if (nsurl_get(url, NSURL_PATH | NSURL_QUERY, &path_query, &len) != @@ -1885,13 +1886,12 @@ struct path_data *urldb_find_url(nsurl *url) assert(url); - if (url_bloom != NULL) { - if (bloom_search_str(url_bloom, - nsurl_access(url), - nsurl_length(url)) == false) { - return NULL; - } - } + if (url_bloom != NULL) { + if (bloom_search_hash(url_bloom, + nsurl_hash(url)) == false) { + return NULL; + } + } scheme = nsurl_get_component(url, NSURL_SCHEME); if (scheme == NULL) -- cgit v1.2.3