Use qsizetype instead of int in QByteArrayMatcher

Change-Id: Id32dc567fa0359ad281d34fcf88c46484f87ce2c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Sona Kurazyan 2020-07-15 17:47:10 +02:00
parent a99bc30e1e
commit b7ccc80526
2 changed files with 7 additions and 8 deletions

View File

@ -128,8 +128,7 @@ QByteArrayMatcher::QByteArrayMatcher()
has the given \a length. \a pattern must remain in scope, but has the given \a length. \a pattern must remain in scope, but
the destructor does not delete \a pattern. the destructor does not delete \a pattern.
*/ */
QByteArrayMatcher::QByteArrayMatcher(const char *pattern, int length) QByteArrayMatcher::QByteArrayMatcher(const char *pattern, qsizetype length) : d(nullptr)
: d(nullptr)
{ {
p.p = reinterpret_cast<const uchar *>(pattern); p.p = reinterpret_cast<const uchar *>(pattern);
p.l = length; p.l = length;
@ -196,7 +195,7 @@ void QByteArrayMatcher::setPattern(const QByteArray &pattern)
setPattern(). Returns the position where the pattern() matched in setPattern(). Returns the position where the pattern() matched in
\a ba, or -1 if no match was found. \a ba, or -1 if no match was found.
*/ */
int QByteArrayMatcher::indexIn(const QByteArray &ba, int from) const qsizetype QByteArrayMatcher::indexIn(const QByteArray &ba, qsizetype from) const
{ {
if (from < 0) if (from < 0)
from = 0; from = 0;
@ -211,7 +210,7 @@ int QByteArrayMatcher::indexIn(const QByteArray &ba, int from) const
most recent call to setPattern(). Returns the position where the most recent call to setPattern(). Returns the position where the
pattern() matched in \a str, or -1 if no match was found. pattern() matched in \a str, or -1 if no match was found.
*/ */
int QByteArrayMatcher::indexIn(const char *str, int len, int from) const qsizetype QByteArrayMatcher::indexIn(const char *str, qsizetype len, qsizetype from) const
{ {
if (from < 0) if (from < 0)
from = 0; from = 0;

View File

@ -52,7 +52,7 @@ class Q_CORE_EXPORT QByteArrayMatcher
public: public:
QByteArrayMatcher(); QByteArrayMatcher();
explicit QByteArrayMatcher(const QByteArray &pattern); explicit QByteArrayMatcher(const QByteArray &pattern);
explicit QByteArrayMatcher(const char *pattern, int length); explicit QByteArrayMatcher(const char *pattern, qsizetype length);
QByteArrayMatcher(const QByteArrayMatcher &other); QByteArrayMatcher(const QByteArrayMatcher &other);
~QByteArrayMatcher(); ~QByteArrayMatcher();
@ -60,8 +60,8 @@ public:
void setPattern(const QByteArray &pattern); void setPattern(const QByteArray &pattern);
int indexIn(const QByteArray &ba, int from = 0) const; qsizetype indexIn(const QByteArray &ba, qsizetype from = 0) const;
int indexIn(const char *str, int len, int from = 0) const; qsizetype indexIn(const char *str, qsizetype len, qsizetype from = 0) const;
inline QByteArray pattern() const inline QByteArray pattern() const
{ {
if (q_pattern.isNull()) if (q_pattern.isNull())
@ -75,7 +75,7 @@ private:
struct Data { struct Data {
uchar q_skiptable[256]; uchar q_skiptable[256];
const uchar *p; const uchar *p;
int l; qsizetype l;
}; };
union { union {
uint dummy[256]; uint dummy[256];