Commit 69832a22 authored by Ulf Hermann's avatar Ulf Hermann

QmlProfiler: Move qHash and operator== for QmlEventType

It makes more sense to have them in the same location as the actual
type.

Change-Id: Ia27970173d14cfe361d4fc007cb461f788350b21
Reviewed-by: default avatarChristian Kandeler <christian.kandeler@theqtcompany.com>
parent e10bc709
......@@ -28,6 +28,7 @@
#include "qmlprofiler_global.h"
#include <QString>
#include <QHash>
namespace QmlProfiler {
......@@ -75,6 +76,14 @@ inline bool operator!=(const QmlEventLocation &location1, const QmlEventLocation
return !(location1 == location2);
}
inline uint qHash(const QmlEventLocation &location)
{
return qHash(location.filename())
^ ((location.line() & 0xfff) // 12 bits of line number
| ((location.column() << 16) & 0xff0000)); // 8 bits of column
}
QDataStream &operator>>(QDataStream &stream, QmlEventLocation &location);
QDataStream &operator<<(QDataStream &stream, const QmlEventLocation &location);
......
......@@ -28,6 +28,7 @@
#include "qmlprofilereventtypes.h"
#include <QString>
#include <QMetaType>
#include <QHash>
namespace QmlProfiler {
......@@ -67,6 +68,25 @@ private:
QDataStream &operator>>(QDataStream &stream, QmlEventType &type);
QDataStream &operator<<(QDataStream &stream, const QmlEventType &type);
inline uint qHash(const QmlEventType &type)
{
return qHash(type.location())
^ (((type.message() << 12) & 0xf000) // 4 bits of message
| ((type.rangeType() << 24) & 0xf000000) // 4 bits of rangeType
| ((type.detailType() << 28) & 0xf0000000)); // 4 bits of detailType
}
inline bool operator==(const QmlEventType &type1, const QmlEventType &type2)
{
return type1.message() == type2.message() && type1.rangeType() == type2.rangeType()
&& type1.detailType() == type2.detailType() && type1.location() == type2.location();
}
inline bool operator!=(const QmlEventType &type1, const QmlEventType &type2)
{
return !(type1 == type2);
}
} // namespace QmlProfiler
Q_DECLARE_METATYPE(QmlProfiler::QmlEventType)
......@@ -34,22 +34,6 @@
namespace QmlProfiler {
inline static uint qHash(const QmlEventType &type)
{
return qHash(type.location().filename()) ^
((type.location().line() & 0xfff) | // 12 bits of line number
((type.message() << 12) & 0xf000) | // 4 bits of message
((type.location().column() << 16) & 0xff0000) | // 8 bits of column
((type.rangeType() << 24) & 0xf000000) | // 4 bits of rangeType
((type.detailType() << 28) & 0xf0000000)); // 4 bits of detailType
}
inline static bool operator==(const QmlEventType &type1, const QmlEventType &type2)
{
return type1.message() == type2.message() && type1.rangeType() == type2.rangeType() &&
type1.detailType() == type2.detailType() && type1.location() == type2.location();
}
class QmlProfilerTraceClientPrivate {
public:
QmlProfilerTraceClientPrivate(QmlProfilerTraceClient *_q, QmlDebug::QmlDebugConnection *client,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment