Skip to content

Commit

Permalink
Don't truncate parameters passed to QStringView::{first/last/from/slice}
Browse files Browse the repository at this point in the history
QStringView doesn't need to convert qsizetype parameters to int.

Change-Id: Iba8b5259ab3ed7a24a57bb6748446fd3e45bb182
Reviewed-by: Volker Hilsheimer <[email protected]>
Reviewed-by: Lars Knoll <[email protected]>
  • Loading branch information
Sona Kurazyan committed Jun 19, 2020
1 parent 96065b7 commit 5b686e2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/corelib/text/qstringview.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,13 @@ class QStringView
}

Q_REQUIRED_RESULT constexpr QStringView first(qsizetype n) const
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); return QStringView(m_data, int(n)); }
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); return QStringView(m_data, n); }
Q_REQUIRED_RESULT constexpr QStringView last(qsizetype n) const
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); return QStringView(m_data + size() - n, int(n)); }
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); return QStringView(m_data + size() - n, n); }
Q_REQUIRED_RESULT constexpr QStringView from(qsizetype pos) const
{ Q_ASSERT(pos >= 0); Q_ASSERT(pos <= size()); return QStringView(m_data + pos, size() - int(pos)); }
{ Q_ASSERT(pos >= 0); Q_ASSERT(pos <= size()); return QStringView(m_data + pos, size() - pos); }
Q_REQUIRED_RESULT constexpr QStringView sliced(qsizetype pos, qsizetype n) const
{ Q_ASSERT(pos >= 0); Q_ASSERT(n >= 0); Q_ASSERT(size_t(pos) + size_t(n) <= size_t(size())); return QStringView(m_data + pos, int(n)); }
{ Q_ASSERT(pos >= 0); Q_ASSERT(n >= 0); Q_ASSERT(size_t(pos) + size_t(n) <= size_t(size())); return QStringView(m_data + pos, n); }
Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QStringView chopped(qsizetype n) const
{ return Q_ASSERT(n >= 0), Q_ASSERT(n <= size()), QStringView(m_data, m_size - n); }

Expand Down

0 comments on commit 5b686e2

Please sign in to comment.