MCPcopy Create free account
hub / github.com/dail8859/NotepadNext / split

Function split

src/ByteArrayUtils.h:59–81  ·  view source on GitHub ↗

Zero-copy split: returns views into 'source'. The source QByteArray must remain alive while using the views.

Source from the content-addressed store, hash-verified

57// Zero-copy split: returns views into 'source'.
58// The source QByteArray must remain alive while using the views.
59inline QList<QByteArrayView> split(const QByteArray& source, const QByteArray& delimiter)
60{
61 QList<QByteArrayView> out;
62
63 const char* base = source.constData();
64 qsizetype len = source.size();
65 qsizetype dlen = delimiter.size();
66
67 qsizetype start = 0;
68
69 while (true) {
70 qsizetype pos = source.indexOf(delimiter, start);
71 if (pos < 0) {
72 out.append(QByteArrayView(base + start, len - start));
73 break;
74 }
75
76 out.append(QByteArrayView(base + start, pos - start));
77 start = pos + dlen;
78 }
79
80 return out;
81}
82
83// Remove duplicates and preserve order.
84inline void removeDuplicates(QList<QByteArrayView>& parts)

Callers 3

removeDuplicateLinesMethod · 0.85
sortMethod · 0.85

Calls 2

QByteArrayViewClass · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected