[babl] hash-table: simplify integer hashing



commit e5fe75a3d2d7480c83d1ece7bfaf965989b18979
Author: Øyvind Kolås <pippin gimp org>
Date:   Sat Dec 31 19:15:29 2016 +0100

    hash-table: simplify integer hashing

 babl/babl-hash-table.c |   14 +++++---------
 1 files changed, 5 insertions(+), 9 deletions(-)
---
diff --git a/babl/babl-hash-table.c b/babl/babl-hash-table.c
index d507cb2..e1c2e56 100644
--- a/babl/babl-hash-table.c
+++ b/babl/babl-hash-table.c
@@ -58,15 +58,11 @@ babl_hash_by_int (BablHashTable *htab,
                   int           id)
 {
   int   hash = 0;
-  int   i;
-
-  for (i = 0; i < sizeof (int); i++)
-  {
-    hash +=  id & 0xFF;
-    hash += (hash << 10);
-    hash ^= (hash >> 6);
-    id >>= 8;
-  }
+  hash +=  id & 0xFF;
+  hash += (hash << 10);
+  hash ^= (hash >> 6);
+  id >>= 8;
+  hash +=  id & 0xFF;
   hash += (hash << 3);
   hash ^= (hash >> 11);
   hash += (hash << 15);


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