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/qstring.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/qstring.h')
-rw-r--r-- | src/corelib/text/qstring.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index cd4af57e13..06c6f668c4 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -336,15 +336,15 @@ public: [[nodiscard]] QString mid(qsizetype position, qsizetype n = -1) const; [[nodiscard]] QString first(qsizetype n) const - { verify(0, n); return QString(data(), n); } + { verify(0, n); return sliced(0, n); } [[nodiscard]] QString last(qsizetype n) const - { verify(0, n); return QString(data() + size() - n, n); } + { verify(0, n); return sliced(size() - n, n); } [[nodiscard]] QString sliced(qsizetype pos) const { verify(pos, 0); return QString(data() + pos, size() - pos); } [[nodiscard]] QString sliced(qsizetype pos, qsizetype n) const { verify(pos, n); return QString(data() + pos, n); } [[nodiscard]] QString chopped(qsizetype n) const - { verify(0, n); return first(size() - n); } + { verify(0, n); return sliced(0, size() - n); } bool startsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; [[nodiscard]] bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept |