celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From griccia...@apache.org
Subject [1/3] celix git commit: CELIX-391: Fix for utils_stringHash
Date Thu, 12 Jan 2017 15:35:51 GMT
Repository: celix
Updated Branches:
  refs/heads/develop 2de5fb464 -> 34c94dae0


CELIX-391: Fix for utils_stringHash


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/3824cfc3
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/3824cfc3
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/3824cfc3

Branch: refs/heads/develop
Commit: 3824cfc3d5bc6fd0b20c284eed3164294ad5a92c
Parents: 147e8bf
Author: Roy Lenferink <lenferinkroy@gmail.com>
Authored: Thu Jan 12 08:51:39 2017 +0100
Committer: Roy Lenferink <lenferinkroy@gmail.com>
Committed: Thu Jan 12 08:51:39 2017 +0100

----------------------------------------------------------------------
 utils/private/src/utils.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/3824cfc3/utils/private/src/utils.c
----------------------------------------------------------------------
diff --git a/utils/private/src/utils.c b/utils/private/src/utils.c
index a9ffd2c..fc4d538 100644
--- a/utils/private/src/utils.c
+++ b/utils/private/src/utils.c
@@ -30,14 +30,13 @@
 
 unsigned int utils_stringHash(const void* strPtr) {
     const char* string = strPtr;
-    unsigned int hash = 5381;
-    unsigned int i = 0;
-    unsigned int len = strlen(string);
+    unsigned int hc = 5381;
+    char ch;
+    while((ch = *string++) != '\0'){
+        hc = (hc << 5) + hc + ch;
+    }
 
-    for(i=0; i < len; i++)
-    { hash = (hash << 5) + (*string) + hash; }
-
-    return hash;
+    return hc;
 }
 
 int utils_stringEquals(const void* string, const void* toCompare) {


Mime
View raw message