hurdextras-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

libfuse/src netnode.c


From: Stefan Siegl
Subject: libfuse/src netnode.c
Date: Sat, 05 Aug 2006 18:53:46 +0000

CVSROOT:        /sources/hurdextras
Module name:    libfuse
Changes by:     Stefan Siegl <stesie>   06/08/05 18:53:46

Modified files:
        src            : netnode.c 

Log message:
        changed hashing algo to use some prime magic, fixed routines to use 
unsigned integers

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libfuse/src/netnode.c?cvsroot=hurdextras&r1=1.2&r2=1.3

Patches:
Index: netnode.c
===================================================================
RCS file: /sources/hurdextras/libfuse/src/netnode.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- netnode.c   13 Apr 2006 22:52:47 -0000      1.2
+++ netnode.c   5 Aug 2006 18:53:46 -0000       1.3
@@ -1,7 +1,7 @@
 /**********************************************************
  * netnode.c
  *
- * Copyright(C) 2004, 2005 by Stefan Siegl <address@hidden>, Germany
+ * Copyright(C) 2004,2005,2006 by Stefan Siegl <address@hidden>, Germany
  * 
  * This is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Publice License,
@@ -24,7 +24,7 @@
 #include "fuse_i.h"
 #include "fuse.h"
 
-#define HASH_BUCKETS 256
+#define HASH_BUCKETS 512
 
 struct hash_element;
 static struct hash_element {
@@ -44,14 +44,16 @@
 
 
 
-static int
+static unsigned int
 fuse_netnode_hash_value(const char *path)
 {
-  int hash = 0;
-  int maxlen = 12; /* use the first 12 chars for hash generation only */
+  unsigned int hash = 0, a = 23, b = 251;
 
-  while(maxlen -- && *path)
-    hash += *(path ++);
+  while(*path)
+    {
+      hash = hash * a + *(path ++);
+      a *= b;
+    }
 
   return hash % HASH_BUCKETS;
 }
@@ -63,7 +65,9 @@
 {
   struct hash_element *hash_el;
   struct netnode *nn;
-  int hash_value = fuse_netnode_hash_value(path);
+
+  unsigned int hash_value = fuse_netnode_hash_value(path);
+  DEBUG("make_netnode", "hash for '%s' is %u\n", path, hash_value);
 
   DEBUG("netnodes_lock", "aquiring rwlock_reader_lock for %s.\n", path);
   rwlock_reader_lock(&fuse_netnodes_lock);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]