forked from qt-creator/qt-creator
Utils: Use always std::strlen
std::strlen is computed at compile time if possible by the compiler. So we don't need this optimization. Change-Id: I31112219df9a3b42fe9d57cdd981f869e6f02dae Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -53,23 +53,10 @@ public:
|
|||||||
|
|
||||||
constexpr SmallStringView() = default;
|
constexpr SmallStringView() = default;
|
||||||
|
|
||||||
template<size_type Size>
|
SmallStringView(const char *characterPointer) noexcept
|
||||||
constexpr
|
: m_pointer(characterPointer)
|
||||||
SmallStringView(const char(&string)[Size]) noexcept
|
, m_size(std::strlen(characterPointer))
|
||||||
: m_pointer(string),
|
|
||||||
m_size(Size - 1)
|
|
||||||
{
|
{
|
||||||
static_assert(Size >= 1, "Invalid string literal! Length is zero!");
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Type,
|
|
||||||
typename = std::enable_if_t<std::is_pointer<Type>::value>
|
|
||||||
>
|
|
||||||
SmallStringView(Type characterPointer) noexcept
|
|
||||||
: m_pointer(characterPointer),
|
|
||||||
m_size(std::strlen(characterPointer))
|
|
||||||
{
|
|
||||||
static_assert(!std::is_array<Type>::value, "Input type is array and not char pointer!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr
|
constexpr
|
||||||
|
|||||||
Reference in New Issue
Block a user