diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 0b5426ef0a..54d00f3e63 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -6575,24 +6575,25 @@ QString QString::number(double n, char f, int prec) } namespace { -template -static ResultList splitString(const StringSource &source, MidMethod mid, const Separtor &sep, +template +static ResultList splitString(const StringSource &source, const QChar *sep, QString::SplitBehavior behavior, Qt::CaseSensitivity cs, const int separatorSize) { ResultList list; int start = 0; int end; int extra = 0; - while ((end = source.indexOf(sep, start + extra, cs)) != -1) { + while ((end = qFindString(source.constData(), source.size(), start + extra, sep, separatorSize, cs)) != -1) { if (start != end || behavior == QString::KeepEmptyParts) - list.append((source.*mid)(start, end - start)); + list.append(source.mid(start, end - start)); start = end + separatorSize; extra = (separatorSize == 0 ? 1 : 0); } if (start != source.size() || behavior == QString::KeepEmptyParts) - list.append((source.*mid)(start, -1)); + list.append(source.mid(start, -1)); return list; } + } // namespace /*! @@ -6615,7 +6616,7 @@ static ResultList splitString(const StringSource &source, MidMethod mid, const S */ QStringList QString::split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const { - return splitString(*this, &QString::mid, sep, behavior, cs, sep.size()); + return splitString(*this, sep.constData(), behavior, cs, sep.size()); } /*! @@ -6638,14 +6639,14 @@ QStringList QString::split(const QString &sep, SplitBehavior behavior, Qt::CaseS */ QVector QString::splitRef(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const { - return splitString >(*this, &QString::midRef, sep, behavior, cs, sep.size()); + return splitString >(QStringRef(this), sep.constData(), behavior, cs, sep.size()); } /*! \overload */ QStringList QString::split(QChar sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const { - return splitString(*this, &QString::mid, sep, behavior, cs, 1); + return splitString(*this, &sep, behavior, cs, 1); } /*! @@ -6654,7 +6655,7 @@ QStringList QString::split(QChar sep, SplitBehavior behavior, Qt::CaseSensitivit */ QVector QString::splitRef(QChar sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const { - return splitString >(*this, &QString::midRef, sep, behavior, cs, 1); + return splitString >(QStringRef(this), &sep, behavior, cs, 1); } /*! @@ -6676,7 +6677,7 @@ QVector QString::splitRef(QChar sep, SplitBehavior behavior, Qt::Cas */ QVector QStringRef::split(const QString &sep, QString::SplitBehavior behavior, Qt::CaseSensitivity cs) const { - return splitString >(*this, &QStringRef::mid, sep, behavior, cs, sep.size()); + return splitString >(*this, sep.constData(), behavior, cs, sep.size()); } /*! @@ -6685,7 +6686,7 @@ QVector QStringRef::split(const QString &sep, QString::SplitBehavior */ QVector QStringRef::split(QChar sep, QString::SplitBehavior behavior, Qt::CaseSensitivity cs) const { - return splitString >(*this, &QStringRef::mid, sep, behavior, cs, 1); + return splitString >(*this, &sep, behavior, cs, 1); } #ifndef QT_NO_REGEXP