From 4c52e5ef954aab240ae170e1f15ab3300366278d Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Sun, 20 Aug 2023 14:26:58 +0200 Subject: [PATCH] Utils: remove a copy from the SmallString default constructor StringDataLayout() is now constexpr too. Not that is useful because we have to wait for constexpr new. Change-Id: I34982c8b17e1935de5c65ec6fc1b01b572170966 Reviewed-by: Qt CI Patch Build Bot Reviewed-by: Reviewed-by: Tim Jenssen --- src/libs/utils/smallstring.h | 12 ++++-------- src/libs/utils/smallstringlayout.h | 4 ++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/libs/utils/smallstring.h b/src/libs/utils/smallstring.h index bd4f708fed1..4a8e7a65907 100644 --- a/src/libs/utils/smallstring.h +++ b/src/libs/utils/smallstring.h @@ -50,15 +50,11 @@ public: using const_reverse_iterator = std::reverse_iterator; using size_type = std::size_t; - static_assert(Size < 64 - ? sizeof(Internal::StringDataLayout) == Size + 1 - : sizeof(Internal::StringDataLayout) == Size + 2, + static_assert(Size < 64 ? sizeof(Internal::StringDataLayout) == Size + 1 + : sizeof(Internal::StringDataLayout) == Size + 2, "Size is wrong"); - constexpr - BasicSmallString() noexcept - : m_data(Internal::StringDataLayout()) - { - } + + constexpr BasicSmallString() = default; constexpr BasicSmallString(const BasicSmallStringLiteral &stringReference) diff --git a/src/libs/utils/smallstringlayout.h b/src/libs/utils/smallstringlayout.h index 6235995d944..7ec48f6b759 100644 --- a/src/libs/utils/smallstringlayout.h +++ b/src/libs/utils/smallstringlayout.h @@ -95,7 +95,7 @@ struct alignas(16) StringDataLayout "Size + 1 must be dividable by 16 if under 64 and Size + 2 must be dividable by " "16 if over 64!"); - StringDataLayout() noexcept { reset(); } + constexpr StringDataLayout() noexcept { reset(); } constexpr StringDataLayout(const char *string, size_type size) noexcept : control{0, true, true} @@ -147,7 +147,7 @@ struct alignas(16) StringDataLayout