# HG changeset patch # User Chris Cannam # Date 1551795517 0 # Node ID 7db29268cf4c90d437401a9d765bf83508f65cf1 # Parent 56045354674996a5dbe648088f0ccaaf9fa21591 Bitfield + reorder for packing diff -r 560453546749 -r 7db29268cf4c base/Clipboard.cpp --- a/base/Clipboard.cpp Tue Mar 05 13:21:55 2019 +0000 +++ b/base/Clipboard.cpp Tue Mar 05 14:18:37 2019 +0000 @@ -16,104 +16,69 @@ #include "Clipboard.h" Clipboard::Point::Point(sv_frame_t frame, QString label) : + m_haveValue(false), + m_haveLevel(false), m_haveFrame(true), + m_haveDuration(false), + m_haveReferenceFrame(false), + m_haveLabel(true), + m_value(0), + m_level(0.f), m_frame(frame), - m_haveValue(false), - m_value(0), - m_haveDuration(false), m_duration(0), - m_haveLabel(true), - m_label(label), - m_haveLevel(false), - m_level(0.f), - m_haveReferenceFrame(false), - m_referenceFrame(frame) + m_referenceFrame(frame), + m_label(label) { } Clipboard::Point::Point(sv_frame_t frame, float value, QString label) : + m_haveValue(true), + m_haveLevel(false), m_haveFrame(true), + m_haveDuration(false), + m_haveReferenceFrame(false), + m_haveLabel(true), + m_value(value), + m_level(0.f), m_frame(frame), - m_haveValue(true), - m_value(value), - m_haveDuration(false), m_duration(0), - m_haveLabel(true), - m_label(label), - m_haveLevel(false), - m_level(0.f), - m_haveReferenceFrame(false), - m_referenceFrame(frame) + m_referenceFrame(frame), + m_label(label) { } Clipboard::Point::Point(sv_frame_t frame, float value, sv_frame_t duration, QString label) : + m_haveValue(true), + m_haveLevel(false), m_haveFrame(true), + m_haveDuration(true), + m_haveReferenceFrame(false), + m_haveLabel(true), + m_value(value), + m_level(0.f), m_frame(frame), - m_haveValue(true), - m_value(value), - m_haveDuration(true), m_duration(duration), - m_haveLabel(true), - m_label(label), - m_haveLevel(false), - m_level(0.f), - m_haveReferenceFrame(false), - m_referenceFrame(frame) + m_referenceFrame(frame), + m_label(label) { } Clipboard::Point::Point(sv_frame_t frame, float value, sv_frame_t duration, float level, QString label) : + m_haveValue(true), + m_haveLevel(true), m_haveFrame(true), + m_haveDuration(true), + m_haveReferenceFrame(false), + m_haveLabel(true), + m_value(value), + m_level(level), m_frame(frame), - m_haveValue(true), - m_value(value), - m_haveDuration(true), m_duration(duration), - m_haveLabel(true), - m_label(label), - m_haveLevel(true), - m_level(level), - m_haveReferenceFrame(false), - m_referenceFrame(frame) + m_referenceFrame(frame), + m_label(label) { } -Clipboard::Point::Point(const Point &point) : - m_haveFrame(point.m_haveFrame), - m_frame(point.m_frame), - m_haveValue(point.m_haveValue), - m_value(point.m_value), - m_haveDuration(point.m_haveDuration), - m_duration(point.m_duration), - m_haveLabel(point.m_haveLabel), - m_label(point.m_label), - m_haveLevel(point.m_haveLevel), - m_level(point.m_level), - m_haveReferenceFrame(point.m_haveReferenceFrame), - m_referenceFrame(point.m_referenceFrame) -{ -} - -Clipboard::Point & -Clipboard::Point::operator=(const Point &point) -{ - if (this == &point) return *this; - m_haveFrame = point.m_haveFrame; - m_frame = point.m_frame; - m_haveValue = point.m_haveValue; - m_value = point.m_value; - m_haveDuration = point.m_haveDuration; - m_duration = point.m_duration; - m_haveLabel = point.m_haveLabel; - m_label = point.m_label; - m_haveLevel = point.m_haveLevel; - m_level = point.m_level; - m_haveReferenceFrame = point.m_haveReferenceFrame; - m_referenceFrame = point.m_referenceFrame; - return *this; -} - bool Clipboard::Point::haveFrame() const { diff -r 560453546749 -r 7db29268cf4c base/Clipboard.h --- a/base/Clipboard.h Tue Mar 05 13:21:55 2019 +0000 +++ b/base/Clipboard.h Tue Mar 05 14:18:37 2019 +0000 @@ -31,8 +31,9 @@ Point(sv_frame_t frame, float value, QString label); Point(sv_frame_t frame, float value, sv_frame_t duration, QString label); Point(sv_frame_t frame, float value, sv_frame_t duration, float level, QString label); - Point(const Point &point); - Point &operator=(const Point &point); + + Point(const Point &point) =default; + Point &operator=(const Point &point) =default; bool haveFrame() const; sv_frame_t getFrame() const; @@ -61,18 +62,20 @@ void setReferenceFrame(sv_frame_t); private: - bool m_haveFrame; + // Order of fields here is chosen to minimise overall size of struct. + // If you change something, check what difference it makes to packing. + bool m_haveValue : 1; + bool m_haveLevel : 1; + bool m_haveFrame : 1; + bool m_haveDuration : 1; + bool m_haveReferenceFrame : 1; + bool m_haveLabel : 1; + float m_value; + float m_level; sv_frame_t m_frame; - bool m_haveValue; - float m_value; - bool m_haveDuration; sv_frame_t m_duration; - bool m_haveLabel; + sv_frame_t m_referenceFrame; QString m_label; - bool m_haveLevel; - float m_level; - bool m_haveReferenceFrame; - sv_frame_t m_referenceFrame; }; Clipboard();