summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qbytearrayview.h
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2023-07-15 21:10:47 +0300
committerAhmad Samir <a.samirh78@gmail.com>2023-09-30 19:29:51 +0300
commit00c1c04bd536aa3db8f0d2ee33261cb4d2a79002 (patch)
treebf7cca5133ef42c308c871c87f2b34aaf578f036 /src/corelib/text/qbytearrayview.h
parentfdd2fc2c711641b3c3a6a02ad331166cb868fa4c (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/qbytearrayview.h')
-rw-r--r--src/corelib/text/qbytearrayview.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/text/qbytearrayview.h b/src/corelib/text/qbytearrayview.h
index 2fe358b619..081cdbbd76 100644
--- a/src/corelib/text/qbytearrayview.h
+++ b/src/corelib/text/qbytearrayview.h
@@ -188,15 +188,15 @@ public:
[[nodiscard]] constexpr char at(qsizetype n) const { return (*this)[n]; }
[[nodiscard]] constexpr QByteArrayView first(qsizetype n) const
- { verify(0, n); return QByteArrayView(data(), n); }
+ { verify(0, n); return sliced(0, n); }
[[nodiscard]] constexpr QByteArrayView last(qsizetype n) const
- { verify(0, n); return QByteArrayView(data() + size() - n, n); }
+ { verify(0, n); return sliced(size() - n, n); }
[[nodiscard]] constexpr QByteArrayView sliced(qsizetype pos) const
{ verify(pos, 0); return QByteArrayView(data() + pos, size() - pos); }
[[nodiscard]] constexpr QByteArrayView sliced(qsizetype pos, qsizetype n) const
{ verify(pos, n); return QByteArrayView(data() + pos, n); }
[[nodiscard]] constexpr QByteArrayView chopped(qsizetype len) const
- { verify(0, len); return first(size() - len); }
+ { verify(0, len); return sliced(0, size() - len); }
[[nodiscard]] constexpr QByteArrayView left(qsizetype n) const
{ if (n < 0 || n > size()) n = size(); return QByteArrayView(data(), n); }