QRingBuffer: merge indexOf() overloads

Change-Id: Icfed4a29bc2ac95b3e0300eb4579751fe7e57e77
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
Alex Trotsenko 2015-05-27 18:25:55 +03:00
parent 5471413522
commit ac4b28ce4d
2 changed files with 1 additions and 19 deletions

View File

@ -188,24 +188,6 @@ void QRingBuffer::clear()
bufferSize = 0;
}
qint64 QRingBuffer::indexOf(char c) const
{
qint64 index = 0;
qint64 j = head;
for (int i = 0; i < buffers.size(); ++i) {
const char *ptr = buffers[i].constData() + j;
j = index + (i == tailBuffer ? tail : buffers[i].size()) - j;
while (index < j) {
if (*ptr++ == c)
return index;
++index;
}
j = 0;
}
return -1;
}
qint64 QRingBuffer::indexOf(char c, qint64 maxLength) const
{
qint64 index = 0;

View File

@ -113,7 +113,7 @@ public:
}
Q_CORE_EXPORT void clear();
Q_CORE_EXPORT qint64 indexOf(char c) const;
inline qint64 indexOf(char c) const { return indexOf(c, size()); }
Q_CORE_EXPORT qint64 indexOf(char c, qint64 maxLength) const;
Q_CORE_EXPORT qint64 read(char *data, qint64 maxLength);
Q_CORE_EXPORT QByteArray read();