Use bit manipulation instead of memory access, improve eet speed with big edje file.
authorcedric <cedric>
Thu, 11 Sep 2008 11:24:13 +0000 (11:24 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 11 Sep 2008 11:24:13 +0000 (11:24 +0000)
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/eet@35946 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/eet_utils.c

index 1785076..10eb540 100644 (file)
@@ -13,21 +13,9 @@ _eet_hash_gen(const char *key, int hash_size)
 {
    int                 hash_num = 0;
    int                 value, i;
+   int                  mask;
    unsigned char       *ptr;
 
-   const int masks[9] =
-     {
-       0x00,
-       0x01,
-       0x03,
-       0x07,
-       0x0f,
-       0x1f,
-       0x3f,
-       0x7f,
-       0xff
-     };
-
    /* no string - index 0 */
    if (!key) return 0;
 
@@ -38,7 +26,8 @@ _eet_hash_gen(const char *key, int hash_size)
      hash_num ^= (value | (value << 8)) >> (i & 0x7);
 
    /* mask it */
-   hash_num &= masks[hash_size];
+   mask = (1 << hash_size) - 1;
+   hash_num &= mask;
    /* return it */
    return hash_num;
 }