Return-Path: X-Original-To: apmail-celix-commits-archive@www.apache.org Delivered-To: apmail-celix-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1572619A19 for ; Mon, 11 Apr 2016 10:54:31 +0000 (UTC) Received: (qmail 9456 invoked by uid 500); 11 Apr 2016 10:54:31 -0000 Delivered-To: apmail-celix-commits-archive@celix.apache.org Received: (qmail 9398 invoked by uid 500); 11 Apr 2016 10:54:30 -0000 Mailing-List: contact commits-help@celix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@celix.apache.org Delivered-To: mailing list commits@celix.apache.org Received: (qmail 8502 invoked by uid 99); 11 Apr 2016 10:54:29 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Apr 2016 10:54:29 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 491D5E03A9; Mon, 11 Apr 2016 10:54:29 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: pnoltes@apache.org To: commits@celix.apache.org Date: Mon, 11 Apr 2016 10:54:55 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [28/50] celix git commit: CELIX-348: Improved string hash. CELIX-348: Improved string hash. Project: http://git-wip-us.apache.org/repos/asf/celix/repo Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/13f34df4 Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/13f34df4 Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/13f34df4 Branch: refs/heads/release/celix-2.0.0 Commit: 13f34df4648ab63e9c5a01afee1a99de06cf467e Parents: 88a7da2 Author: Pepijn Noltes Authored: Wed Feb 10 08:43:50 2016 +0100 Committer: Pepijn Noltes Committed: Wed Feb 10 08:43:50 2016 +0100 ---------------------------------------------------------------------- framework/private/src/utils.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/celix/blob/13f34df4/framework/private/src/utils.c ---------------------------------------------------------------------- diff --git a/framework/private/src/utils.c b/framework/private/src/utils.c index f8e5d1f..a072623 100644 --- a/framework/private/src/utils.c +++ b/framework/private/src/utils.c @@ -29,18 +29,14 @@ #include "utils.h" unsigned int utils_stringHash(void * string) { - char * str = (char *) string; + unsigned int hash = 5381; + unsigned int i = 0; + unsigned int len = strlen(string); - unsigned int hash = 1315423911; - unsigned int i = 0; - unsigned int len = strlen(str); + for(i=0; i < len; i++) + { hash = (hash << 5) + (*string) + hash; } - for(i = 0; i < len; str++, i++) - { - hash ^= ((hash << 5) + (*str) + (hash >> 2)); - } - - return hash; + return hash; } int utils_stringEquals(void * string, void * toCompare) { @@ -134,4 +130,4 @@ FRAMEWORK_EXPORT int utils_compareServiceIdsAndRanking(long servId, long servRan } return result; -} \ No newline at end of file +}