summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qvarlengtharray.h
Commit message (Collapse)AuthorAgeFilesLines
* Cast away -Wclass-memaccess warnings in QVarLengthArray methodsEdward Welbourne2018-08-201-3/+3
| | | | | | | | | | | | With g++ 8.2.0, I get warnings when a QVarLengthArray<QString> calls remove() or prepend(), as some tests in tst_QVarLengthArray do, as they call memmove() "writing to an object of type ‘class QString’ with no trivial copy-assignment; use copy-assignment or copy-initialization instead"; which may indeed be a good argument for not using QVarLengthArray<QString>, but its own tests do. Change-Id: I4f8a64948b32a54e67a285df4ec7788f60739ffb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* fixup oversight in rvalue overloads of operator+=() and operator<<()Eric Lemanissier2018-03-261-2/+2
| | | | | | | ammends 4dee5446bee9c7417bf6f5dc44294a0b7238a9ba Change-Id: Ia0ca27644eb71815a93d6e76681b8a9e61a4e7ab Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Add missing rvalue overloads of operator+=() and operator<<()Christian Ehrlicher2018-03-071-0/+4
| | | | | | | | | | | | | | | They were forgotten when the overloads for append()/push_back() were added in Qt 5.6 [ChangeLog][QtCore][QVarLengthArray] Added missing rvalue overload of operator+=() and operator<<() [ChangeLog][QtCore][QVector] Added missing rvalue overload of operator+=() and operator<<() Change-Id: I20fedfba2bf282773bd1f9cf2c8ec06f05896a7d Reviewed-by: Martin Smith <martin.smith@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Merge remote-tracking branch 'origin/5.9' into 5.11Liang Qi2018-02-141-2/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf src/corelib/animation/qvariantanimation.cpp src/corelib/global/qglobal.cpp src/corelib/global/qlogging.cpp src/corelib/io/qprocess_win.cpp src/corelib/json/qjsonarray.cpp src/corelib/tools/qsimd_p.h src/corelib/tools/qtimezoneprivate_p.h src/corelib/xml/qxmlstream_p.h src/gui/kernel/qsimpledrag.cpp src/gui/kernel/qsimpledrag_p.h src/plugins/generic/generic.pro src/plugins/platforms/cocoa/qcocoamenu.mm src/widgets/styles/qmacstyle_mac.mm tests/auto/concurrent/qtconcurrentmap/BLACKLIST tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp tests/auto/gui/kernel/qwindow/BLACKLIST tests/auto/widgets/dialogs/qmessagebox/BLACKLIST Change-Id: I508d686cf20f7f8cc6a7119b9bc7c3bbb505c58e
| * Silence GCC 8 warning on memcpy of movable typesThiago Macieira2018-02-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | This is similar to commit 342bb5b03a76d1428fafb8e1532d66e172bd1c0b. From GCC 8: qarraydataops.h:84:17: error: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘class QStringRef’ with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Werror=class-memaccess] [etc.] Change-Id: I41d006aac5bc48529845fffd150e817e64973bec Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Add rvalue overload of insert/prepend to QVarLengthArray and QVectorAllan Sandfeld Jensen2018-01-201-2/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Improves performance and STL compatibility by adding rvalue versions of prepend and insert. [ChangeLog][QtCore][QVarLengthArray] Added rvalue overloads of prepend and insert. [ChangeLog][QtCore][QVector] Added rvalue overloads of prepend and insert. [ChangeLog][QtCore][QVarLengthArray] Can now contain movable but non-copyable types, such as std::unique_ptr. Change-Id: I6c946acc5b67502c91c52ac5dea67cedb1af93a5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Array-backed containers: add shrink_to_fit for STL compatibilityGiuseppe D'Angelo2017-04-121-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Side note: QHash has squeeze(), but there's no shrink_to_fit on std::unordered_map. [ChangeLog][QtCore][QByteArray] Added shrink_to_fit(). [ChangeLog][QtCore][QString] Added shrink_to_fit(). [ChangeLog][QtCore][QVarLengthArray] Added shrink_to_fit(). [ChangeLog][QtCore][QVector] Added shrink_to_fit(). Change-Id: Ifd7d28c9bed70727be6308f0191a188201784f61 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-03-281-0/+1
|\| | | | | | | | | | | | | | | | | Conflicts: examples/examples.pro tests/auto/corelib/tools/qchar/tst_qchar.cpp tests/auto/other/qaccessibility/accessiblewidgets.h Change-Id: I426696c40ab57d14dc295b8103152cede79f244c
| * Merge remote-tracking branch 'origin/5.8' into 5.9Liang Qi2017-03-271-0/+1
| |\ | | | | | | | | | Change-Id: Icdd71e9713725bda9c305e338f5c8b41a92ed8e8
| | * QVarLengthArray: fix compilation with GCC 7Marc Mutz2017-03-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a warning-turned-Werror in qdistancefield.cpp: In member function ‘void QVarLengthArray<T, Prealloc>::realloc(int, int) [with T = bool; int Prealloc = 256]’, inlined from ‘void makeDistanceField(QDistanceFieldData*, const QPainterPath&, int, int)’ at ../../include/QtCore/../../../../qt5/qtbase/src/corelib/tools/qvarlengtharray.h:275:10: ../../include/QtCore/../../../../qt5/qtbase/src/corelib/tools/qvarlengtharray.h:390:19: error: ‘void* memcpy(void*, const void*, size_t)’: specified size between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=] memcpy(ptr, oldPtr, copySize * sizeof(T)); ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Apparently GCC cannot rule out that copySize may be negative in the call to memcpy. Put GCC on the right track by adding a Q_ASSUME. Change-Id: I63e3801e52ebe2a7f77e3a97ef03ec3869319c8c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | | Remove unused QPodList classMarc Mutz2017-03-221-4/+0
|/ / | | | | | | | | | | | | | | It's private API, the last in-tree user was removed in acbd7999, but failed to remove the class. Do it now. Change-Id: I26294b535d80b419a2f545a4783014b493a5dc93 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | QVarLengthArray: add rvalue overload of append/push_backMarc Mutz2017-02-251-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Improves performance when appending temporaries, esp. since the aliasing fix in the lvalue overload in 0f730ef made that overload correct, but a bit slower across reallocs. The unit tests already also pass rvalues, so the function is covered in the existing tests. [ChangeLog][QtCore][QVarLengthArray] Added rvalue overloads of append() and push_back(). Change-Id: If3a6970f03a160cba5b42d33d32d3d18948f6ce3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | Merge remote-tracking branch 'origin/5.8' into 5.9Liang Qi2017-02-241-5/+15
|\| | | | | | | | | | | | | Conflicts: mkspecs/features/moc.prf Change-Id: Ia71c8e3b3185f7c999bf226d0675051b10b8740b
| * QVarLengthArray: fix appending an already-contained itemMarc Mutz2017-02-171-5/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Like the lvalue QVector::append() overload, when we reallocate, we need to take a copy of the function's argument because the reference will get stale upon reallocation. Add a test. [ChangeLog][QtCore][QVarLengthArray] Fixed a bug involving appending an item already in the container to the container again. Change-Id: I06eeed6cb383dd5924e47a302bb3d1666d04c8e8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Do not use QTypeInfo::isStatic anymoreMarc Mutz2017-02-221-2/+2
|/ | | | | | | | | | | | | | | | ... except in QList. When dafa3618 introduced isRelocatable and QTypeInfoQuery, the intention was to decouple the memory layout of QList from the reallocation optimizations in QVector. This never happened, as QVector (and QVarLengthArray) continue to use isStatic to this day. Fix by porting both QVector and QVLA to QTypeInfoQuery and isRelocatable. Change-Id: I6951f2cf21f0cbb24e2dbd38f80f1bd82007d394 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix possible loss of data warningJesus Fernandez2017-01-241-1/+1
| | | | | | | | warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data while compiling class template member function 'QVarLengthArray<T,Prealloc>::QVarLengthArray(std::initializer_list<T>)' Change-Id: I36f5ef65ec1f511eac7f3ad1a4717d18f7dc9ce4 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Don't crash on QVLA construction from an empty std::initializer_listThiago Macieira2016-12-091-1/+2
| | | | | | | | | | | | | | | | | | | | | The C++ standard says in [support.initlist.access]/1: constexpr const E* begin() const noexcept; Returns: A pointer to the beginning of the array. If size() == 0 the values of begin() and end() are unspecified but they shall be identical. So we can't assume it's non-null. I didn't want to remove the Q_ASSERT, so passing a non-null pointer to append() remains required. This patch simply won't call append() if the initializer list is empty. This was already tested, but the failure is with a compiler that is not part of the Qt CI. Task-number: QTBUG-57277 Change-Id: Iaeecaffe26af4535b416fffd1489806872b412ee Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-04-291-3/+4
|\ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: mkspecs/features/qml_module.prf mkspecs/features/qt_common.prf src/gui/text/qzip.cpp src/plugins/platforms/cocoa/qnsview.mm src/plugins/platforms/windows/array.h src/testlib/qtestcase.cpp src/widgets/dialogs/qfilesystemmodel.h Change-Id: Ie41c5868415b81f7693c80e045497035504bb210
| * Silence MSVC warnings when using certain std algorithmsMarc Mutz2016-04-261-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The MSVC STL warns when passing naked pointers as non-bounded iterators to algorithms such as std::equal and std::copy, in an attempt to inform users that the range specified by that iterator has an implicit minimum size that the caller of the algorithm must ensure is met: warning C4996: 'std::_Equal1': Function call with parameters that may be unsafe - \ this call relies on the caller to check that the passed values are correct. To \ disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to \ use Visual C++ 'Checked Iterators' When building Qt, as well as when building user projects with qmake (cf. 0a76b6bc7f98900ea884cd10ccca1a332e5bdba5), we globally disable this warning (with -D_SCL_SECURE_NO_WARNINGS), but since we started using STL algorithms in public headers (e.g. in qvector.h), users get this warning in their own projects now, unless they, too, define said macro. But such a requirement is against the Qt policy to have headers that are warning-free as much as possible. The suggested way of fixing this warning is to wrap the naked pointer in a stdext::unchecked_array_iterator before passing it to the algorithm, cf. examples in https://msdn.microsoft.com/en-us/library/ttcz0bys%28v=vs.120%29.aspx or, together with the capacity-made-explicit, in a stdext::checked_array_iterator. To avoid ifdefs for platforms that don't have these extensions (which, incidentally, for the unchecked case, includes MSVC 2012), wrap the calls in macros. The end game here is to drop -D_SCL_SECURE_NO_WARNINGS, at least for public headers, even though this commit also adds the wrapper to implementation and private header files. An alternative to the wrapper would have been the version of std::equal that takes four iterators. However, that is a C++14 library feature, while this version of Qt still needs to compile with a C++98 compiler, and, more importantly, there isn't, and never will be, a corresponding 4-iterator version of std::copy. Task-number: QTBUG-47948 Done-with: Stephen Kelly <steveire@gmail.com> Change-Id: I1bbab257fb5f1c5042939c382a412b596112ff26 Reviewed-by: Stephen Kelly <ske@ableton.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>
* Merge remote-tracking branch 'origin/5.5' into devLiang Qi2015-04-061-0/+9
|\ | | | | | | Change-Id: If9fd98525b6b4ca07e5e006fc98bf372a73b8a21
| * QVLA: Add operator= for initializer listsKai Koehne2015-04-041-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a dedicated operator=(std::initializer_list) that first resizes the QCLA, and then replaces the elements one by one. This should be usually faster than creating a temporary QCLA and then copying it, except for the case where the new array does not fit into the allocated stack - but this is IMO nothing to optimize for. Task-number: QTBUG-45041 Change-Id: I147d6d01186b1ca3c635b2c8365d8f6e638ce6fe GPush-Base: 08de3113051e1289f0de0651ec5647c9ee6feb27 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QVarLengthArray: add {const_,reverse_iterator}, {c,}r{begin,end}()Marc Mutz2015-04-051-0/+9
| | | | | | | | | | | | | | | | | | [ChangeLog][QtCore][QVarLengthArray] Added rbegin(), crbegin(), rend(), crend(), and reverse_iterator and const_reverse_iterator typedefs. Task-number: QTBUG-25919 Change-Id: Ifda5d420802a3594c3181f54036279f16a7da16e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QVarLengthArray: add relational operators <,<=,>,>=Marc Mutz2015-04-051-0/+30
|/ | | | | | | | | | std::vector has them, too. [ChangeLog][QtCore][QVarLengthArray] Added relational operators <, <=, >, >= if the element type supports operator<. Change-Id: I69e16d361fd4738a56b292ebfa78316d28871eda Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QVarLengthArray: Do not require operator!= for element comparisonKai Koehne2015-03-231-5/+4
| | | | | | | | | | The documentation claims that operator== is needed, not operator!=. While at it, we can also replace the loop with std::equal, which might even allow STL implementations to choose a hand-optimized version of the algorithm for C++ builtin types ... Change-Id: I988b326d6af3b767526952e303468e18ff6594f9 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* QVarLengthArray: Add initializer_list constructorKai Koehne2015-03-231-0/+11
| | | | | | | | | | | | | | | | | Implement an initializer_list constructor, which was probably just forgotten so far. Technically this is a SC incompatible change, since QVarLengthArray<int> array = {10}; will now create an array with one element 10, instead of an empty array with a reserved size of 10. Anyhow, keeping the inconsistency with the STL / other Qt containers here would certainly do more harm than good in the long run. Task-number: QTBUG-45047 Change-Id: I4675880f93e141181250939942fa32300916b0e3 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Add QVarLengthArray::{indexOf,lastIndexOf,contains} functionshjk2014-01-091-0/+49
| | | | | | | | | | [ChangeLog][QtCore][QVarLengthArray] Added the indexOf, lastIndexOf and contains functions to QVarLengthArray. These functions make the class more similar to QVector. Change-Id: I9bd2b22bd8b7151c2d17aede36e5f2126570600b Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Remove redundant checks in some tools classesJędrzej Nowacki2013-09-131-2/+2
| | | | | | | | | | | | | | | | | | | | This is a simple optimisation allowed to us by the fact that all platforms we run on use two's complement for the signed integers. The trick works as long as one of the two signed integers is known beforehand to be non-negative: - by definition, for any signed integer i, i <= INT_MAX - by definition, for any unsigned integer u, u >= 0 - given a signed integer x >= 0, 0U <= uint(x) <= uint(INT_MAX) - therefore, given another signed integer y of whatever value, uint(x) < uint(y) ←→ x < y && y >= 0 The trick is an optimisation because the compiler doesn't know that one of the two sides is always non-negative. Otherwise, it would do the same optimisation. Change-Id: If256ec0df4e06335805af8010bb67ce5fd3e065a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove qCopy from QVarLengthArrayGiuseppe D'Angelo2013-09-041-1/+2
| | | | | | | | QtAlgorithms is getting deprecated, see http://www.mail-archive.com/development@qt-project.org/msg01603.html Change-Id: I854f64ebd6d83718b1bcb3c70a1697e38243296c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QVarLengthArray - check if iterators arguments are valid (in debugmode)Thorbjørn Martsum2013-07-121-0/+10
| | | | | | | This add checks on iterators on insert and erase. Change-Id: I41d96e038d74668cc1df10b6d42cde4b82f8a696 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Prevent negative size in QBitArray, QVector and QVarLengthArray ctors.Mitch Curtis2013-06-051-0/+2
| | | | | | | | | | | | | | | | | | As shown in QTBUG-24345, QBitArray will exhibit invalid reads when initialised with a negative size and run under valgrind. QVector and QVarLengthArray both cause a crash if initialised with a negative size. This patch enforces sizes greater than or equal to 0 with asserts and existing if statements, and hence impose no performance penalty for release builds. Task-number: QTBUG-24345 Task-number: QTBUG-30037 Change-Id: I9a969f6016e0a59904a60bbfe9e5360e6f523b87 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove QT_{BEGIN,END}_HEADER macro usageSergio Ahumada2013-01-291-4/+0
| | | | | | | | | | | The macro was made empty in ba3dc5f3b56d1fab6fe37fe7ae08096d7dc68bcb and is no longer necessary or used. Discussed-on: http://lists.qt-project.org/pipermail/development/2013-January/009284.html Change-Id: Id2bb2e2cabde059305d4af5f12593344ba30f001 Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: hjk <hjk121@nokiamail.com>
* QVarLengthArray: add squeeze functionPeter Kümmel2013-01-281-0/+5
| | | | | | | Add function to move back data to the stack. Change-Id: Ic78a368459bce68629e29602e4eeae2e1afe398b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* QVarLengthArray: use memory on stack if possiblePeter Kümmel2012-10-111-5/+10
| | | | | | | | | | After allocating memory on the heap it is ATM not possible to use the memory on the stack again, QVarLengthArray then uses/resizes only the memory on the heap. But the memory on stack could be used if it is big enough. Change-Id: I566003c25dd1093eb6ba8087a1e5378a11712934 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make QVarLengthArray exception safe in case of OOMPeter Kümmel2012-10-111-26/+22
| | | | | | | | | | | | | After a exception is thrown in resize(), QVarLengthArray has an invalid state with ptr == 0. On the next resize call when malloc returns a valid pointer, oldPtr is 0 and it could crash in memcpy because the pointer to the source is 0. The patch ensures the valid pointer isn't overwritten with NULL. When exceptions are disabled the user must ensure that malloc will not fail. Change-Id: Id12a5e3e1eacc551e4d1b64cba8e8414cfebd6e1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* QVarLengthArray: provide STL-compatible member function namesMarc Mutz2012-09-191-0/+9
| | | | | | | | | This allows, among other things, to use QVarLengthArray as the target of a std::back_insert_iterator. Change-Id: I507f612a23da854bf865780aa0a7e6312f4a896b Reviewed-by: João Abecasis <joao.abecasis@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QVarLengthArray: C++11-ify insert/erase signaturesMarc Mutz2012-08-301-6/+6
| | | | | | | | | | | | | | | | | | | In C++11, container insert and erase operations take const_iterators instead of iterators. This is a bug fix compared to C++98, where the mere lookup step of a lookup-or-insert operation had to be done using (mutable) iterators, which is particularly worrisome for Qt containers that are implicitly shared, because of the unneeded detach in the positive case. QVarLengthArray is not implicitly shared, but for consistency, the signatures should be changed here, too. The reason this commit contains only the change to QVarLengthArray is that this is by far the easiest container. The implictly shared containers are harder, because detaching invalidates other iterators (more than the sister STL container would). Change-Id: Ib3d98360bfe376b782b9d1283c5fa3555e8a719e Reviewed-by: João Abecasis <joao.abecasis@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Simplify the size of the QVarLengthArray buffer.Thiago Macieira2012-05-031-2/+1
| | | | | | | | | | | The previous calculation was too complex for no good reason. QVarLengthArray actually doesn't change the size after this change due to padding, but we don't need to include the padding in our own calculation. Task-number: QTBUG-25113 Change-Id: I72ea214f0d96870ecf8ff65737e7ca14e19afc7a Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Deprecate qMemCopy/qMemSet in favour of their stdlib equivilents.Robin Burchell2012-04-111-2/+2
| | | | | | | | | | | | | | | | | | Just like qMalloc/qRealloc/qFree, there is absolutely no reason to wrap these functions just to avoid an include, except to pay for it with worse runtime performance. On OS X, on byte sizes from 50 up to 1000, calling memset directly is 28-15% faster(!) than adding an additional call to qMemSet. The advantage on sizes above that is unmeasurable. For qMemCopy, the benefits are a little more modest: 16-7%. Change-Id: I98aa92bb765aea0448e3f20af42a039b369af0b3 Reviewed-by: Giuseppe D'Angelo <dangelog@gmail.com> Reviewed-by: John Brooks <john.brooks@dereferenced.net> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Remove all calls to, and deprecate qMalloc, qRealloc and qFree.Robin Burchell2012-03-311-5/+6
| | | | | | | | | | | | | | | | | | Callers should just call the standard allocation functions directly. Adding an extra function call onto all basic memory management for the sake of making it instrumentable in rare cases isn't really fair to everyone else. What's more, this wasn't completely reliable, as not everything was using them in a number of places. Memory management can still be overridden using tricks like LD_PRELOAD if needed. Their aligned equivilents cannot be deprecated, as no standard equivilents exist, although investigation into posix_memalign(3) is a possibility for the future. Change-Id: Ic5f74b14be33f8bc188fe7236c55e15c36a23fc7 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* containers: add C++11-style c{begin,end}() as alias for const{Begin,End}()Marc Mutz2012-03-171-0/+2
| | | | | | | | | | | | | | | | | | C++11 adds cbegin()/cend() functions for the same reason Qt has constBegin()/constEnd(). This patch adds these functions to the Qt containers with the same implementation as constBegin()/constEnd(). It also fixes the return types in the documentation of existing constFind() functions (documentation only). C++11 only adds cbegin()/cend() (and crbegin()/crend(), which Qt doesn't have). In particular, it doesn't add cfind(), so I didn't supply these, even though Qt comes with constFind(). This is a forward-port of https://qt.gitorious.org/qt/qt/merge_requests/1365. Change-Id: Ida086b64246b24e25254eafbcb06c8e33388502b Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Remove "All rights reserved" line from license headers.Jason McDonald2012-01-301-1/+1
| | | | | | | | | | As in the past, to avoid rewriting various autotests that contain line-number information, an extra blank line has been inserted at the end of the license text to ensure that this commit does not change the total number of lines in the license header. Change-Id: I311e001373776812699d6efc045b5f742890c689 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Remove use of QT_MODULE from libraryGunnar Sletta2012-01-251-1/+0
| | | | | | | | | | These defines were there to aid in the commercial licensing scheme we used long ago, and are no longer needed. Keep a QT_MODULE(x) define so other modules continue compiling. Change-Id: I8fd76cd5270df8f14aee746b6cf32ebf7c23fec7 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Update contact information in license headers.Jason McDonald2012-01-231-1/+1
| | | | | | | Replace Nokia contact email address with Qt Project website. Change-Id: I431bbbf76d7c27d8b502f87947675c116994c415 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update copyright year in license headers.Jason McDonald2012-01-051-1/+1
| | | | | Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Implement (and unit test) simple QVarLengthArray::first()/last().Robin Burchell2012-01-021-0/+4
| | | | | | | | | Pure syntactical sugar, to match up with what the other container classes offer. Change-Id: I0f97de011923d9d204cca0fa906b059dc5054a89 Reviewed-by: João Abecasis <joao.abecasis@nokia.com> Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>