forked from qt-creator/qt-creator
QmlProfiler: Add some missing bits to QmlEvent
We want move constructor, move assignment, ==, and !=. Also, drop some unreachable code. Change-Id: I65f24d7ba0f146ad37ec4b7c438b47d4abc3d688 Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
@@ -29,6 +29,20 @@
|
|||||||
|
|
||||||
namespace QmlProfiler {
|
namespace QmlProfiler {
|
||||||
|
|
||||||
|
bool operator==(const QmlEvent &event1, const QmlEvent &event2)
|
||||||
|
{
|
||||||
|
if (event1.timestamp() != event2.timestamp() || event1.typeIndex() != event2.typeIndex())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// This is not particularly efficient, but we also don't need to do this very often.
|
||||||
|
return event1.numbers<QVarLengthArray<qint64>>() == event2.numbers<QVarLengthArray<qint64>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const QmlEvent &event1, const QmlEvent &event2)
|
||||||
|
{
|
||||||
|
return !(event1 == event2);
|
||||||
|
}
|
||||||
|
|
||||||
enum SerializationType {
|
enum SerializationType {
|
||||||
OneByte = 0,
|
OneByte = 0,
|
||||||
TwoByte = 1,
|
TwoByte = 1,
|
||||||
@@ -153,10 +167,8 @@ static qint8 minimumType(const QmlEvent &event, quint16 length, quint16 origBits
|
|||||||
case FourByte:
|
case FourByte:
|
||||||
ok = (event.number<qint32>(i) == event.number<qint64>(i));
|
ok = (event.number<qint32>(i) == event.number<qint64>(i));
|
||||||
break;
|
break;
|
||||||
case EightByte:
|
|
||||||
ok = true;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
|
// EightByte isn't possible, as (1 << type) == origBitsPerNumber / 8 then.
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,6 +66,12 @@ struct QmlEvent {
|
|||||||
assignData(other);
|
assignData(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QmlEvent(QmlEvent &&other)
|
||||||
|
{
|
||||||
|
memcpy(this, &other, sizeof(QmlEvent));
|
||||||
|
other.m_dataType = Inline8Bit; // prevent dtor from deleting the pointer
|
||||||
|
}
|
||||||
|
|
||||||
QmlEvent &operator=(const QmlEvent &other)
|
QmlEvent &operator=(const QmlEvent &other)
|
||||||
{
|
{
|
||||||
if (this != &other) {
|
if (this != &other) {
|
||||||
@@ -79,6 +85,15 @@ struct QmlEvent {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QmlEvent &operator=(QmlEvent &&other)
|
||||||
|
{
|
||||||
|
if (this != &other) {
|
||||||
|
memcpy(this, &other, sizeof(QmlEvent));
|
||||||
|
other.m_dataType = Inline8Bit;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
~QmlEvent()
|
~QmlEvent()
|
||||||
{
|
{
|
||||||
clearPointer();
|
clearPointer();
|
||||||
@@ -290,6 +305,9 @@ private:
|
|||||||
friend QDataStream &operator<<(QDataStream &stream, const QmlEvent &event);
|
friend QDataStream &operator<<(QDataStream &stream, const QmlEvent &event);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool operator==(const QmlEvent &event1, const QmlEvent &event2);
|
||||||
|
bool operator!=(const QmlEvent &event1, const QmlEvent &event2);
|
||||||
|
|
||||||
QDataStream &operator>>(QDataStream &stream, QmlEvent &event);
|
QDataStream &operator>>(QDataStream &stream, QmlEvent &event);
|
||||||
QDataStream &operator<<(QDataStream &stream, const QmlEvent &event);
|
QDataStream &operator<<(QDataStream &stream, const QmlEvent &event);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user