src/hbcore/core/hbsharedcache.cpp
changeset 28 b7da29130b0e
parent 21 4633027730f5
--- a/src/hbcore/core/hbsharedcache.cpp	Thu Sep 02 20:44:51 2010 +0300
+++ b/src/hbcore/core/hbsharedcache.cpp	Fri Sep 17 08:32:10 2010 +0300
@@ -25,6 +25,7 @@
 
 #include "hbsharedcache_p.h"
 #include "hbsharedmemorymanager_p.h"
+#include "hbhash_p.h"
 #ifdef HB_BIN_CSS
 #include "hbcssconverterutils_p.h"
 #endif
@@ -70,21 +71,6 @@
 }
 
 /*!
-    return hash value for \a string.
-*/
-quint32 HbSharedCache::hash(const QStringRef &string)
-{
-    quint32 hashValue = 0;
-    const QChar *data = string.unicode();
-    int size = string.size();
-    while (size--) {
-        hashValue = data->unicode() + (hashValue << 6) + (hashValue << 16) - hashValue;
-        ++data;
-    }
-    return hashValue;
-}
-
-/*!
     adds \a offset using key \a key. \a itemType is the type of the structure,
     where offset points to.
     Only acceptable separator for key is '/'.
@@ -154,24 +140,20 @@
         //try first in prebuilt offset map.
         length -= WidgetMLFileExtension.length();
         QStringRef widgetname(&filePath, position, length);
-        HbOffsetItem find(hash(widgetname));
+        HbOffsetItem find(hbHash(widgetname));
         const HbOffsetItem *end = mOffsetItems + mOffsetItemCount;
         const HbOffsetItem *offsetItem = qBinaryFind(mOffsetItems, end, find);
         if (offsetItem != end) {
-#ifdef CSSBIN_TRACES
-            qDebug() << "Offset item found from static cache map for widget: " << widgetname;
-#endif
+            THEME_CSSBIN_DEBUG() << "Offset item found from static cache map for widget: " << widgetname;
             qint32 tableSize = 0;
             const HbLayoutIndexItem *begin = layoutIndexItemBegin(
                     offsetItem->offsetLayoutIndexTable, &tableSize);
             if (begin) {
                 const HbLayoutIndexItem *end = begin + tableSize;
-                HbLayoutIndexItem find(hash(QStringRef(&layout)), hash(QStringRef(&section)));
+                HbLayoutIndexItem find(hbHash(QStringRef(&layout)), hbHash(QStringRef(&section)));
                 const HbLayoutIndexItem *item = qBinaryFind(begin, end, find);
                 if (item != end) {
-#ifdef CSSBIN_TRACES
-                    qDebug() << "Layout definition offset found for layout: " << layout;
-#endif
+                    THEME_CSSBIN_DEBUG() << "Layout definition offset found for layout: " << layout;
                     offset = item->offset;
                 }
             }
@@ -221,13 +203,11 @@
             length -= CSSFileExtension.length();
         }
         QStringRef widgetname(&key, position, length);
-        HbOffsetItem find(hash(widgetname));
+        HbOffsetItem find(hbHash(widgetname));
         const HbOffsetItem *end = mOffsetItems + mOffsetItemCount;
         const HbOffsetItem *offsetItem = qBinaryFind(mOffsetItems, end, find);
         if (offsetItem != end) {
-#ifdef CSSBIN_TRACES
-            qDebug() << "Offset item found from static cache map for widget: " << widgetname;
-#endif
+            THEME_CSSBIN_DEBUG() << "Offset item found from static cache map for widget: " << widgetname;
             offset = (isColorCSS) ? offsetItem->offsetColorCSS : offsetItem->offsetCSS;
         }
     }
@@ -405,9 +385,7 @@
 
     //server creates the semaphore.
     Semaphore = new QSystemSemaphore(SemaphoreName, 1, QSystemSemaphore::Create);
-#ifdef CSSBIN_TRACES
-    qDebug() << "css offset items total: " << mOffsetItemCount;
-#endif
+    THEME_CSSBIN_DEBUG() << "css offset items total: " << mOffsetItemCount;
 }
 
 /*!