diff options
author | Ahmad Samir <a.samirh78@gmail.com> | 2023-07-15 21:10:47 +0300 |
---|---|---|
committer | Ahmad Samir <a.samirh78@gmail.com> | 2023-09-30 19:29:51 +0300 |
commit | 00c1c04bd536aa3db8f0d2ee33261cb4d2a79002 (patch) | |
tree | bf7cca5133ef42c308c871c87f2b34aaf578f036 /src/corelib/text/qstringview.h | |
parent | fdd2fc2c711641b3c3a6a02ad331166cb868fa4c (diff) |
String classes: make first/last/chopped() delegate to sliced()
De-duplicates code.
Change-Id: Id29511e7e571ed14f9e3cfd4355b901d81ea2562
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/text/qstringview.h')
-rw-r--r-- | src/corelib/text/qstringview.h | 6 |
1 files changed, 3 insertions, 3 deletions
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; } |