diff options
author | Marc Mutz <marc.mutz@qt.io> | 2023-02-13 10:33:09 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-02-13 12:34:23 +0000 |
commit | 22b480c2e67135c79280eaee65c57317a07c60be (patch) | |
tree | dd45c92831cb9bd76d55476b2c434fcb1c29bfff /src | |
parent | bdfe061d485f1f693adac60f5d527bd700521143 (diff) |
Fix qbswap(UniqueId)
The function should be inline and noexcept, to avoid function-call
overhead when using it. It also should be defined in the same
namespace as its argument, to make ADL work.
Change-Id: I01964121e043bc20abea53c00e81db26eed6308e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
(cherry picked from commit d75f7e69e4decb6f02ad64748f3a814dbd5acd00)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/serialbus/qcancommondefinitions.cpp | 8 | ||||
-rw-r--r-- | src/serialbus/qcancommondefinitions.h | 7 |
2 files changed, 6 insertions, 9 deletions
diff --git a/src/serialbus/qcancommondefinitions.cpp b/src/serialbus/qcancommondefinitions.cpp index c48d5c1..c220154 100644 --- a/src/serialbus/qcancommondefinitions.cpp +++ b/src/serialbus/qcancommondefinitions.cpp @@ -3,8 +3,6 @@ #include "qcancommondefinitions.h" -#include <QtCore/qendian.h> - #ifndef QT_NO_DEBUG_STREAM #include <QtCore/QDebug> #endif // QT_NO_DEBUG_STREAM @@ -68,12 +66,6 @@ QT_BEGIN_NAMESPACE An enum is used to avoid implicit conversions to or from unsigned int. */ -QtCanBus::UniqueId qbswap(QtCanBus::UniqueId src) -{ - const auto uintval = qbswap_helper(qToUnderlying(src)); - return QtCanBus::UniqueId{uintval}; -} - #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, QtCanBus::DataSource source) { diff --git a/src/serialbus/qcancommondefinitions.h b/src/serialbus/qcancommondefinitions.h index de60180..54e2728 100644 --- a/src/serialbus/qcancommondefinitions.h +++ b/src/serialbus/qcancommondefinitions.h @@ -4,6 +4,7 @@ #ifndef QCANCOMMONDEFINITIONS_H #define QCANCOMMONDEFINITIONS_H +#include <QtCore/qendian.h> #include <QtCore/qsysinfo.h> #include <QtCore/qtconfigmacros.h> #include <QtCore/qtypes.h> @@ -36,9 +37,13 @@ enum class MultiplexState : quint8 { enum class UniqueId : quint32 {}; +inline UniqueId qbswap(UniqueId src) noexcept +{ + return UniqueId{qbswap_helper(qToUnderlying(src))}; +} + } // namespace QtCanBus -Q_SERIALBUS_EXPORT QtCanBus::UniqueId qbswap(QtCanBus::UniqueId src); #ifndef QT_NO_DEBUG_STREAM |