From 96f3768384ea4fcfbb38fa9645e13b1cae7830b0 Mon Sep 17 00:00:00 2001 From: Kenneth G Raeburn Date: Thu, 16 Aug 1990 18:43:01 +0000 Subject: [tytso] Don't #ifdef out class_restrict. (Auditor: raeburn.) [raeburn] Fix up hash function to be faster. (Auditor: tytso.) --- server/class.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'server/class.c') diff --git a/server/class.c b/server/class.c index 80c0d90..0525631 100644 --- a/server/class.c +++ b/server/class.c @@ -331,8 +331,6 @@ char *class; return(NULLZACLT); } -#ifdef notdef -/* currently not used */ /* * restrict class by associating it with the acl structure acl. * return ZERR_NONE if no error, or ZSRV_NOCLASS if there is no such @@ -361,7 +359,6 @@ ZAcl_t *acl; /* fell off the end, no match */ return(ZSRV_NOCLASS); } -#endif notdef /* * restrict class by registering it and associating it with the acl @@ -417,17 +414,16 @@ static unsigned int hash(string) char *string; { - register unsigned int hval = 0; + register int hval = 0; register unsigned char *cp = (unsigned char *) string; while (*cp) { - if (isupper(*cp)) { - hval = (hval + (tolower(*cp)) * HASHMUL) % HASHSIZE; - cp++; - } else - hval = (hval + (*cp++) * HASHMUL) % HASHSIZE; + hval *= HASHMUL; + hval += (isascii(*cp) && isupper(*cp)) ? tolower(*cp) : *cp; + hval %= HASHSIZE; + cp++; } - return(hval); + return hval; } /* set up the class.instance in the class_buf, and return its hash val */ -- cgit v1.2.3