From 3e1049e5369994af2a451a0cdcea518b359ca57d Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Thu, 27 Feb 2025 15:27:28 +0100 Subject: [PATCH] Utils: Use [[likely]] and [[unlikely]] Change-Id: I82cd1873c57c01cf39796e624e97dc9f0fdfbf0f Reviewed-by: Thomas Hartmann --- src/libs/utils/smallstring.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libs/utils/smallstring.h b/src/libs/utils/smallstring.h index f502c7e7489..8f3f4eed310 100644 --- a/src/libs/utils/smallstring.h +++ b/src/libs/utils/smallstring.h @@ -112,13 +112,13 @@ public: ~BasicSmallString() noexcept { - if (Q_UNLIKELY(hasAllocatedMemory())) + if (hasAllocatedMemory()) [[unlikely]] Memory::deallocate(m_data.data()); } BasicSmallString(const BasicSmallString &other) noexcept { - if (Q_LIKELY(other.isShortString() || other.isReadOnlyReference())) + if (other.isShortString() || other.isReadOnlyReference()) [[likely]] m_data = other.m_data; else new (this) BasicSmallString{other.data(), other.size()}; @@ -126,10 +126,10 @@ public: BasicSmallString &operator=(const BasicSmallString &other) noexcept { - if (Q_LIKELY(this != &other)) { + if (this != &other) [[likely]] { this->~BasicSmallString(); - if (Q_LIKELY(other.isShortString() || other.isReadOnlyReference())) + if (other.isShortString() || other.isReadOnlyReference()) [[likely]] m_data = other.m_data; else new (this) BasicSmallString{other.data(), other.size()}; @@ -146,7 +146,7 @@ public: BasicSmallString &operator=(BasicSmallString &&other) noexcept { - if (Q_LIKELY(this != &other)) { + if (this != &other) [[likely]] { this->~BasicSmallString(); m_data = std::move(other.m_data); @@ -202,7 +202,7 @@ public: void reserve(size_type newCapacity) noexcept { if (fitsNotInCapacity(newCapacity)) { - if (Q_UNLIKELY(hasAllocatedMemory())) { + if (hasAllocatedMemory()) { m_data.setPointer(Memory::reallocate(m_data.data(), newCapacity)); m_data.setAllocatedCapacity(newCapacity); } else {