From 00c1c04bd536aa3db8f0d2ee33261cb4d2a79002 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Sat, 15 Jul 2023 21:10:47 +0300 Subject: String classes: make first/last/chopped() delegate to sliced() De-duplicates code. Change-Id: Id29511e7e571ed14f9e3cfd4355b901d81ea2562 Reviewed-by: Thiago Macieira --- src/corelib/text/qstringview.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/corelib/text/qstringview.h') diff --git a/src/corelib/text/qstringview.h b/src/corelib/text/qstringview.h index 6a1806d602..05e5ec3fdb 100644 --- a/src/corelib/text/qstringview.h +++ b/src/corelib/text/qstringview.h @@ -220,15 +220,15 @@ public: } [[nodiscard]] constexpr QStringView first(qsizetype n) const noexcept - { verify(0, n); return QStringView(m_data, n); } + { verify(0, n); return sliced(0, n); } [[nodiscard]] constexpr QStringView last(qsizetype n) const noexcept - { verify(0, n); return QStringView(m_data + size() - n, n); } + { verify(0, n); return sliced(size() - n, n); } [[nodiscard]] constexpr QStringView sliced(qsizetype pos) const noexcept { verify(pos, 0); return QStringView(m_data + pos, size() - pos); } [[nodiscard]] constexpr QStringView sliced(qsizetype pos, qsizetype n) const noexcept { verify(pos, n); return QStringView(m_data + pos, n); } [[nodiscard]] constexpr QStringView chopped(qsizetype n) const noexcept - { verify(0, n); return QStringView(m_data, m_size - n); } + { verify(0, n); return sliced(0, m_size - n); } constexpr void truncate(qsizetype n) noexcept { verify(0, n); ; m_size = n; } -- cgit v1.2.3