OSDN Git Service

move qCRC32() to qcorecommon_p header
authorIvailo Monev <xakepa10@laimg.moc>
Thu, 11 Jul 2019 00:02:41 +0000 (00:02 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Thu, 11 Jul 2019 00:02:41 +0000 (00:02 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
src/core/kernel/qmetaobject_p.h
src/core/qcorecommon_p.h

index ff4949c..212a4e3 100644 (file)
 // We mean it.
 //
 
-#include <QtCore/qobjectdefs.h>
+#include <qobjectdefs.h>
+#include <qcorecommon_p.h>
 
 #ifndef QT_NO_QOBJECT
-#  include <QtCore/qobject_p.h>
+#  include <qobject_p.h>
 #endif
 
+#ifndef QT_NO_COMPRESS
 #define QT_CACHE_NORMALIZED_TYPE
-
-#if !defined(QT_NO_COMPRESS) && defined(QT_CACHE_NORMALIZED_TYPE)
-#  include <zlib.h>
 #endif
 
 QT_BEGIN_NAMESPACE
@@ -165,13 +164,7 @@ static inline bool is_space(char s)
 }
 #endif
 
-#if !defined(QT_NO_COMPRESS) && defined(QT_CACHE_NORMALIZED_TYPE)
-static inline quint32 qCRC32(const char *data, uint len)
-{
-    quint32 crc_32 = ::crc32(0, 0, 0);
-    return ::crc32(crc_32, reinterpret_cast<const uchar *>(data), len);
-}
-
+#ifdef QT_CACHE_NORMALIZED_TYPE
 typedef QHash<quint32, QByteArray> QNormalizedTypeHash;
 Q_GLOBAL_STATIC(QNormalizedTypeHash, qGlobalNormalizedTypeHash);
 #endif
@@ -180,7 +173,7 @@ Q_GLOBAL_STATIC(QNormalizedTypeHash, qGlobalNormalizedTypeHash);
 static inline QByteArray normalizeTypeInternal(const char *t, const char *e)
 {
     const int len = e - t;
-#if !defined(QT_NO_COMPRESS) && defined(QT_CACHE_NORMALIZED_TYPE)
+#ifdef QT_CACHE_NORMALIZED_TYPE
     const quint32 cachekey = qCRC32(t, len);
     QByteArray cached = qGlobalNormalizedTypeHash()->value(cachekey);
     if (!cached.isEmpty()) {
@@ -238,7 +231,7 @@ static inline QByteArray normalizeTypeInternal(const char *t, const char *e)
     result.replace("unsigned short", "ushort");
     result.replace("unsigned char", "uchar");
 
-#if !defined(QT_NO_COMPRESS) && defined(QT_CACHE_NORMALIZED_TYPE)
+#ifdef QT_CACHE_NORMALIZED_TYPE
     qGlobalNormalizedTypeHash()->insert(cachekey, result);
 #endif
 
index 1d8544b..bc736e1 100644 (file)
@@ -3,6 +3,10 @@
 
 #include "qstring.h"
 
+#ifndef QT_NO_COMPRESS
+#  include <zlib.h>
+#endif
+
 QT_BEGIN_NAMESPACE
 
 #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L
@@ -31,6 +35,15 @@ static inline void report_error(int code, const char *where, const char *what)
         qWarning("%s: %s failure: %s", where, what, qPrintable(qt_error_string(code)));
 }
 
+
+#ifndef QT_NO_COMPRESS
+static inline quint32 qCRC32(const char *data, uint len)
+{
+    quint32 crc_32 = ::crc32(0, 0, 0);
+    return ::crc32(crc_32, reinterpret_cast<const uchar *>(data), len);
+}
+#endif
+
 QT_END_NAMESPACE
 
 #endif // QCORECOMMON_P_H