mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-31 03:50:20 -07:00
Change splitToViews() return type to QVector
This commit is contained in:
parent
3d6dccc689
commit
ff707ea5af
6 changed files with 18 additions and 15 deletions
|
@ -28,15 +28,17 @@
|
|||
|
||||
#include "bytearray.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QByteArray>
|
||||
|
||||
QList<QByteArray> Utils::ByteArray::splitToViews(const QByteArray &in, const QByteArray &sep, const QString::SplitBehavior behavior)
|
||||
QVector<QByteArray> Utils::ByteArray::splitToViews(const QByteArray &in, const QByteArray &sep, const QString::SplitBehavior behavior)
|
||||
{
|
||||
if (sep.isEmpty())
|
||||
return {in};
|
||||
|
||||
QList<QByteArray> ret;
|
||||
|
||||
QVector<QByteArray> ret;
|
||||
ret.reserve((behavior == QString::KeepEmptyParts)
|
||||
? (1 + (in.size() / sep.size()))
|
||||
: (1 + (in.size() / (sep.size() + 1))));
|
||||
int head = 0;
|
||||
while (head < in.size()) {
|
||||
int end = in.indexOf(sep, head);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue