summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qringbuffer.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QRingBuffer::reserve(): remove superfluous assertAlex Trotsenko2016-10-221-1/+0
| | | | | | | | 'bytes' is checked against MaxByteArraySize in the beginning and remains unchanged in the function. Change-Id: Ibd4091b95837db16cf45f845d485bfb189317125 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QRingBuffer: add packet modeAlex Trotsenko2016-07-231-22/+24
| | | | | | | | | | | As a special case, setting the value of chunk size to zero forces QRingBuffer to produce a separate QByteArray on each call which appends the data. So, this enables a packet mode where portions of data are stored independently from each other. Change-Id: I2d0b331211901a289da7d4533e974f06830b5590 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* CoreLib: use const (and const APIs) moreAnton Kudryavtsev2016-04-181-6/+6
| | | | | | | | | | For CoW types const methods will be called. Mark store_persistent_indexes() as const, because this method does not modify the object. Change-Id: Ic867913b4fb5aaebfbaaffe1d3be45cf7b646403 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QRingBuffer::read(): remove unneeded byte array allocationAlex Trotsenko2016-02-241-1/+0
| | | | | | | QRingBuffer already works fine with empty list of arrays. Change-Id: I5cd388709686d2980efa3d5129c726e75c0b5c09 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* QRingBuffer: add append(const char *, qint64) functionAlex Trotsenko2016-02-011-0/+14
| | | | | | | This allows to remove a code duplication in several places. Change-Id: I49f56e951682dbd2968923654a12cba5199a2502 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* Updated license headersJani Heikkinen2016-01-151-14/+20
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* QRingBuffer: improve indexOf() performanceAlex Trotsenko2015-09-031-7/+6
| | | | | | | Use memchr() instead of scan cycle. Change-Id: Ic77a3e5ad4c5f6c7d2a1df12d150eac45d620744 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QRingBuffer: avoid allocation in c'torAlex Trotsenko2015-08-271-17/+36
| | | | | | | | | | | | | | | | | | Reduces creation time and memory consumption when the buffer is unused. Robin's benchmark: QBENCHMARK { QFile file(filename); } reports the following results (run with -median 10 -iterations 524288): before: 0.00028 msecs per iteration (total: 149, iterations: 524288) after: 0.00017 msecs per iteration (total: 93, iterations: 524288). Change-Id: Ied4e7caeca794b94260b8fc59b3ba656f4719c30 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* QRingBuffer: allow to search from any positionAlex Trotsenko2015-08-271-12/+25
| | | | | | Change-Id: I348cd9da88fc81c3dd0789ce8cce9d80c4524e24 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QRingBuffer::reserveFront(): do not leave empty array in buffer listAlex Trotsenko2015-07-101-2/+6
| | | | | | | Fix the corner case when called on empty buffer. Change-Id: I1316de7fbe69f3db40a7fdde06336e53d82675c9 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* Unify QByteArray::MaxSize and MaxAllocSizeUlf Hermann2015-06-161-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | We have established the maximum size qAllocMore can deal with in commit 880986be2357a1f80827d038d770dc2f80300201 and we should use it. The maximum size for byte arrays is reduced by one byte as with the previous code we could make qAllocMore produce ((1 << 31) - extra) by passing (1 << 30). That is not a problem for qAllocMore itself (as long as extra > 0) but it's hard to verify that no related code casts the total sum back to signed int, which would overflow to -1. To make the compiler inline access to the maximum size, a private enum MaxByteArraySize is provided, which can be used in internal code. This fixes the merge of commits 880986be2357a1f80827d038d770dc2f80300201 and c70658d301e274c3aaa1fb6cebe2a5e56db12779 Change-Id: Idb04856f7c2e53ef383063e7555d3083020ff2b7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QRingBuffer: merge indexOf() overloadsAlex Trotsenko2015-05-281-18/+0
| | | | | Change-Id: Icfed4a29bc2ac95b3e0300eb4579751fe7e57e77 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* Deinline QRingBuffer classAlex Trotsenko2015-05-201-0/+327
Reduce the size of .text section in QtCore by 4.5KB and in QtNetwork by 26.5KB. Change-Id: If7998776166b9681c1e4b24c51d40444aa996d7a Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>