forked from qt-creator/qt-creator
Utils: Fix fix for string size
It was not using the whole short string size. Change-Id: Id6f6d4d0241ef74dbc0fe766bc1e19e8671e0b94 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io> Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
This commit is contained in:
@@ -90,33 +90,25 @@ struct alignas(16) StringDataLayout
|
|||||||
, reference{{string}, size, 0}
|
, reference{{string}, size, 0}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QT_WARNING_PUSH
|
|
||||||
QT_WARNING_DISABLE_CLANG("-Wunsafe-buffer-usage")
|
|
||||||
template<size_type Size>
|
template<size_type Size>
|
||||||
constexpr StringDataLayout(const char (&string)[Size]) noexcept
|
constexpr StringDataLayout(const char (&string)[Size]) noexcept
|
||||||
{
|
{
|
||||||
if constexpr (Size + 1 <= MaximumShortStringDataAreaSize) {
|
constexpr auto size = Size - 1;
|
||||||
control = {Size - 1, false, false};
|
if constexpr (size <= MaximumShortStringDataAreaSize) {
|
||||||
for (size_type i = 0; i < Size; ++i)
|
control = {size, false, false};
|
||||||
|
for (size_type i = 0; i < size; ++i)
|
||||||
shortString[i] = string[i];
|
shortString[i] = string[i];
|
||||||
#if defined(__cpp_lib_is_constant_evaluated) && __cpp_lib_is_constant_evaluated >= 201811L
|
#if defined(__cpp_lib_is_constant_evaluated) && __cpp_lib_is_constant_evaluated >= 201811L
|
||||||
if (std::is_constant_evaluated()) {
|
if (std::is_constant_evaluated()) {
|
||||||
for (size_type i = Size; i < MaximumShortStringDataAreaSize; ++i)
|
for (size_type i = size; i < MaximumShortStringDataAreaSize; ++i)
|
||||||
shortString[i] = 0;
|
shortString[i] = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
control = {0, true, true};
|
control = {0, true, true};
|
||||||
#if defined(__cpp_lib_is_constant_evaluated) && __cpp_lib_is_constant_evaluated >= 201811L
|
reference = {{string}, size, 0};
|
||||||
if (std::is_constant_evaluated()) {
|
|
||||||
for (size_type i = 0; i < sizeof(dummy); ++i)
|
|
||||||
dummy[i] = 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
reference = {{string}, Size - 1, 0};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QT_WARNING_POP
|
|
||||||
|
|
||||||
constexpr static size_type shortStringCapacity() noexcept
|
constexpr static size_type shortStringCapacity() noexcept
|
||||||
{
|
{
|
||||||
@@ -166,33 +158,25 @@ struct alignas(16) StringDataLayout<MaximumShortStringDataAreaSize,
|
|||||||
, reference{{string}, size, 0}
|
, reference{{string}, size, 0}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QT_WARNING_PUSH
|
|
||||||
QT_WARNING_DISABLE_CLANG("-Wunsafe-buffer-usage")
|
|
||||||
template<size_type Size>
|
template<size_type Size>
|
||||||
constexpr StringDataLayout(const char (&string)[Size]) noexcept
|
constexpr StringDataLayout(const char (&string)[Size]) noexcept
|
||||||
{
|
{
|
||||||
if constexpr (Size + 1 <= MaximumShortStringDataAreaSize) {
|
constexpr auto size = Size - 1;
|
||||||
control = {Size - 1, false, false};
|
if constexpr (size <= MaximumShortStringDataAreaSize) {
|
||||||
for (size_type i = 0; i < Size; ++i)
|
control = {size, false, false};
|
||||||
|
for (size_type i = 0; i < size; ++i)
|
||||||
shortString[i] = string[i];
|
shortString[i] = string[i];
|
||||||
#if defined(__cpp_lib_is_constant_evaluated) && __cpp_lib_is_constant_evaluated >= 201811L
|
#if defined(__cpp_lib_is_constant_evaluated) && __cpp_lib_is_constant_evaluated >= 201811L
|
||||||
if (std::is_constant_evaluated()) {
|
if (std::is_constant_evaluated()) {
|
||||||
for (size_type i = Size; i < MaximumShortStringDataAreaSize; ++i)
|
for (size_type i = size; i < MaximumShortStringDataAreaSize; ++i)
|
||||||
shortString[i] = 0;
|
shortString[i] = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
control = {0, true, true};
|
control = {0, true, true};
|
||||||
#if defined(__cpp_lib_is_constant_evaluated) && __cpp_lib_is_constant_evaluated >= 201811L
|
reference = {{string}, size, 0};
|
||||||
if (std::is_constant_evaluated()) {
|
|
||||||
for (size_type i = 0; i < sizeof(dummy); ++i)
|
|
||||||
dummy[i] = 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
reference = {{string}, Size - 1, 0};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QT_WARNING_POP
|
|
||||||
|
|
||||||
void copyHere(const StringDataLayout &other) noexcept
|
void copyHere(const StringDataLayout &other) noexcept
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user