Skip to content

Commit

Permalink
QRingBuffer: merge indexOf() overloads
Browse files Browse the repository at this point in the history
Change-Id: Icfed4a29bc2ac95b3e0300eb4579751fe7e57e77
Reviewed-by: Oswald Buddenhagen <[email protected]>
  • Loading branch information
Alex Trotsenko committed May 28, 2015
1 parent 5471413 commit ac4b28c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 19 deletions.
18 changes: 0 additions & 18 deletions src/corelib/tools/qringbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/corelib/tools/qringbuffer_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class QRingBuffer
}

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();
Expand Down

0 comments on commit ac4b28c

Please sign in to comment.