From f34ebe53f56fc06ebc7c72be55249a58da5c4e3f Mon Sep 17 00:00:00 2001 From: jbj Date: Thu, 11 Mar 1999 02:08:42 +0000 Subject: [PATCH] Matt's cache hit algorithm. CVS patchset: 2877 CVS date: 1999/03/11 02:08:42 --- url.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/url.c b/url.c index 19200a1..5b89952 100644 --- a/url.c +++ b/url.c @@ -48,6 +48,16 @@ urlinfo *newUrlinfo(void) return u; } +static int urlStrcmp(const char *str1, const char *str2) +{ + if (str1 && str2) { + return (strcmp(str1, str2)); + } else + if (str1 != str2) + return -1; + return 0; +} + static void findUrlinfo(urlinfo **uret, int mustAsk) { urlinfo *u; @@ -73,21 +83,18 @@ static void findUrlinfo(urlinfo **uret, int mustAsk) * a) both items are not NULL and don't compare. * b) either of the items is not NULL. */ - if ((u->service && ou->service && strcmp(u->service, ou->service)) || - (u->service != ou->service)) - continue; - if ((u->host && ou->host && strcmp(u->host, ou->host)) || - (u->host != ou->host)) - continue; - if ((u->user && ou->user && strcmp(u->user, ou->user)) || - (u->user != ou->user)) - continue; - if ((u->password && ou->password && strcmp(u->password, ou->password))|| - (u->password != ou->password)) - continue; - if ((u->portstr && ou->portstr && strcmp(u->portstr, ou->portstr)) || - (u->portstr != ou->portstr)) - continue; + if (urlStrcmp(u->service, ou->service)) + continue; + if (urlStrcmp(u->service, ou->service)) + continue; + if (urlStrcmp(u->host, ou->host)) + continue; + if (urlStrcmp(u->user, ou->user)) + continue; + if (urlStrcmp(u->password, ou->password)) + continue; + if (urlStrcmp(u->portstr, ou->portstr)) + continue; break; /* Found item in cache */ } -- 2.7.4