summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qvector.h
Commit message (Collapse)AuthorAgeFilesLines
* Unify all mid() functions in QtBase.Jędrzej Nowacki2014-05-161-5/+10
| | | | | | | | | | | | | | | | | | | Up to now, Qt had at least 3 different implementations of the mid(). Only QString::mid implementation was not crashing on edge cases and was protected against overflows, therefore I picked that one as the base implementation, even if it has weird semantics for an invalid input. As a side effect QVector::mid was slightly optimized to not detach in all cases (which follows current QList behavior). Documentation of QVector::mid and QList::mid was updated to not mention "copy of data" which could suggest that the mid() result is detached. QStringRef::mid was fixed and now it follows general Qt behavior, by returning a null value for a null input. Change-Id: Ie9ff5d98372bd193d66508e6dd92b6ed1180ad9b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2014-05-061-3/+11
|\ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: mkspecs/qnx-x86-qcc/qplatformdefs.h src/corelib/global/qglobal.h src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp src/opengl/qgl.cpp src/opengl/qglpixelbuffer.cpp src/opengl/qglshaderprogram.cpp tests/auto/opengl/qglthreads/tst_qglthreads.cpp Change-Id: Iaba137884d3526a139000ca26fee02bb27b5cdb5
| * Deprecate setSharable in Qt containersThiago Macieira2014-04-241-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ability to set a container to be unsharable has very little use and it costs us an extra conditional for every refcount up and possibly down. This change is a no-op for current Qt 5. It shuffles a few things around just so Qt can compile if you define QT_NO_UNSHARABLE_CONTAINERS. That is done to ease the fixing of the code in Qt 6 and to make my life easier: I'll keep that defined in my local Qt build so I can catch any misuses of this deprecated API. The newly deprecated methods are not marked QT_DEPRECATED because the bootstrapped tools wouldn't build -- they're built with QT_NO_DEPRECATED defined, which causes build errors. [ChangeLog][QtCore] The setSharable() and isSharable() functions in Qt containers has been deprecated and will be removed in Qt 6. New applications should not use this feature, while old applications that may be using this (undocumented) feature should port away from it. Discussed-on: http://lists.qt-project.org/pipermail/development/2014-February/015724.html Change-Id: I789771743dcaed6a43eccd99382f8b3ffa61e479 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Merge "Merge remote-tracking branch 'origin/stable' into dev" into ↵Mitch Curtis2014-03-311-0/+9
|\| | | | | | | refs/staging/dev
| * Remove level 4 compiler warnings from MSVC.David Schulz2014-03-151-0/+9
| | | | | | | | | | | | | | | | | | | | Task-number: QTBUG-7233 Change-Id: I52067e3a22e98a62fd87415906e54a54ff2d6b49 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com> Reviewed-by: Oliver Wolff <oliver.wolff@digia.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com> Reviewed-by: Dave McClelland
* | QVector: add removeOne(), removeAll() for QList compatibilityMarc Mutz2014-03-261-0/+19
|/ | | | | | | | | | Eases migration from QList to QVector. [ChangeLog][QtCore][QVector] Added removeOne(), removeAll() for QList compatibility. Change-Id: I4211afb2e077c187d0a39f0ac4528f0c66721fb3 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Retain compiler warning stateKurt Pattyn2014-01-211-2/+5
| | | | | | | | | Added push and pop pragma warning statements. Suppression of warnings should not propagate to user code. Therefore, suppression of warnings is restricted to the file where it is used. Change-Id: Ib7973cbc0205ebbe75e002d035e44fd9b447460f Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Fix crash when constructing a QVector with an empty initializer list.Volker Krause2014-01-181-5/+9
| | | | | | | | | Data::allocate(0) returns a pointer to read-only memory, updating d->size will segfault. The safety check for this exists in all other QVector ctors already. Change-Id: Ida0fe4182de56ee62c7f91e8652cfafbfd7b8410 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QVector: add some functions missing for QList compatMarc Mutz2013-10-111-9/+14
| | | | | | | | | | | | Eases migration from QList to QVector. Had to rename the 'length' parameter to mid() to suppress -Wshadow warnings. Task-number: QTBUG-3781 Change-Id: I755c6caefe4de81ea42a81b1c76aab728e639613 Reviewed-by: Lars Knoll <lars.knoll@digia.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 QLinkedList / QVectorGiuseppe D'Angelo2013-09-111-2/+4
| | | | | | | | | QtAlgorithms is getting deprecated, see http://www.mail-archive.com/development@qt-project.org/msg01603.html Change-Id: I5f7c2a6b3588a07113061c018e2870f476bea5a7 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Merge remote-tracking branch 'origin/stable' into devSergio Ahumada2013-09-071-1/+1
|\ | | | | | | Change-Id: I9ee4176f0a0078908d49896508826154c9f71530
| * Compile in strict-iterator mode under MSVCThiago Macieira2013-09-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MSVC doesn't like operator->() returning a pointer to non-aggregate. So we must make sure that the expanded code does not try to call it by doing: abegin->~T(); Instead, we make an implicit call to operator T*() with that static_cast<T* >. If abegin is a non-strict iterator, it's already a T*, so the static_cast is a no-op. qvector.h(645) : error C2839: invalid return type 'int *' for overloaded 'operator ->' Change-Id: I06f983bab7677cb60ef3913cdce349e26896bfb6 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* | QVector - optimize removeLast (and takeLast + pop_back)Thorbjørn Martsum2013-08-161-8/+8
| | | | | | | | | | | | | | | | | | | | In our benchmarks this makes removeLast more than twice as fast. (That is on my core I7 laptop with gcc on linux). It changes the alloc test to be an assert rather than an if. Change-Id: Id55195b9b7880e54a89be4dd9d6228d94aff23c7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QVector - check if iterators arguments are valid (in debugmode)Thorbjørn Martsum2013-07-121-1/+9
|/ | | | | | | This adds a check of the iterator values in erase and insert. Change-Id: I28e660153dbfc5f0054a5b25cba2c5725c678a81 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Prevent negative size in QBitArray, QVector and QVarLengthArray ctors.Mitch Curtis2013-06-051-2/+4
| | | | | | | | | | | | | | | | | | 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>
* QVector: Fix signedness warning in assert.Friedemann Kleint2013-04-111-1/+1
| | | | | | | Task-number: QTBUG-30331 Change-Id: I91b346b36162e8146a05babd24afa4bfb7259bec Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* QVector - removeLast optimizeThorbjørn Martsum2013-03-071-1/+18
| | | | | | | | | | | | In case somebody uses QVector as a stack, it is not fair to have takeLast, removeLast and pop_back to do way too much work. This is still very slow compared to std::vector::pop_back (mostly due implicit sharing), however it is more than a factor faster than before. Change-Id: I636872675e80c8ca0c8ebc94b04f587a2dcd6d8d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QVector - add functions takeFirst and takeLastThorbjørn Martsum2013-03-071-0/+2
| | | | | | | | This patch adds takeFirst and takeLast which are functions that QList also has. Change-Id: I761f90b529774edc8fa96e07c6fcf76226123b20 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QVector - add remove functionsThorbjørn Martsum2013-03-071-2/+4
| | | | | | | | | | | This patch adds the functions removeFirst() and removeLast(). Functions that QList has. Beside making these functions, pop_back and pop_front are redirected to these rather than calling erase. Change-Id: Ifc5f8a78e33f436f06f21095a920ec5d4311fd6f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2013-03-051-2/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: configure qmake/generators/mac/pbuilder_pbx.cpp src/corelib/kernel/qtimerinfo_unix.cpp src/plugins/platforms/cocoa/qcocoabackingstore.mm src/plugins/platforms/cocoa/qcocoawindow.mm src/plugins/platforms/windows/qwindowswindow.cpp src/plugins/platforms/xcb/qglxintegration.cpp Change-Id: I8d125fe498f5304874e6976b53f588d3e98a66ac
| * Fix QVector detaching in one thread while another destroys it.Jędrzej Nowacki2013-02-201-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | The patch adds handling for a case when a QVector is shared between two threads. In such scenario detaching in one thread could collide with destruction in the other one, causing a memory leak or assert in debug mode. Task-number: QTBUG-29134 Change-Id: Idbff250d9cfc6cf83174954ea91dbf41f8ea4aa4 Reviewed-by: Olivier Goffart <ogoffart@woboq.com> 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>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix warnings when using QImage as QtConcurrent::mapped return typeLiang Qi2012-11-021-3/+3
| | | | | | | | Task-number: QTBUG-27391 Change-Id: I68b37ffa645be21d4d23b205bc052540b9aba7f4 Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: João Abecasis <joao@abecasis.name>
* detach() safely in QVector::erase(), and update callers to not detach.Andreas Hartmetz2012-10-191-4/+6
| | | | | | | | | | | | | | | | remove() can use non-detaching iterators internally before calling erase(), which hasn't been exploited so far, so that the detach() in erase() never actually detached. When using erase() from outside, you can't do it legally without calling begin() or end() that detach() before erase() is called. Now remove() doesn't detach anymore, and detaching in erase() works. With new tests that fail after changing only the erase() callers and pass again after fixing erase(). Change-Id: I47c0a9e362dce8628ec566f5437d951755de96c8 Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* Make sure functions returning iterators have an iterator as parameterThiago Macieira2012-10-191-0/+11
| | | | | | | | | | | | | | | | | | | | | The IA-64 C++ ABI does not encode the return type for non-template functions (QVector is the template, not the function), which means that these two functions have the same signature: Node *QVector<Node>::begin() typename class QTypedArrayData<Node>::iterator QVector<Node>::begin() [both are _ZN7QVectorI4NodeE5beginEv] When linking compilation units compiled with different QT_STRICT_ITERATORS settings, only one of the two out-of-line copies will survive. Depending on the ABI, we may have a problem: the ABI can say that a function returning a structure takes an implicit first parameter, which a function returning a regular pointer doesn't. Task-number: QTBUG-27277 Change-Id: I57a59e5a7c46f55faabfe85c073dca89d2a7bbf3 Reviewed-by: Jan Kundrát <jkt@flaska.net> 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>
* compile without CamelCase headersOswald Buddenhagen2012-09-111-2/+1
| | | | | | | | for faster bootstrapping without a full syncqt run Change-Id: I648f0a8fb09be021590c46e8e5e15667a316c817 Reviewed-by: Qt Doc Bot <qt_docbot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com>
* Fix performance regression when appending one vector to anotherLars Knoll2012-09-071-2/+6
| | | | | | | | | | | | When appending a QVector to an existing vector the code would unconditionally realloc the vector instead of first checking whether we can do without. This gives a quadratic behaviour when repeatedly appending a vector to another. Change-Id: I2cd81253e6a8aec0bc4402e6fbda262435080966 Reviewed-by: Qt Doc Bot <qt_docbot@qt-project.org> Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Silence clang warning in QVector::reallocData()Kent Hansen2012-07-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | qvector.h:459:30: warning: destination for this 'memcpy' call is a pointer to dynamic class 'QImage'; vtable pointer will be overwritten [-Wdynamic-class-memaccess] ::memcpy(dst, srcBegin, (srcEnd - srcBegin) * sizeof(T)); ~~~~~~~~ ^ qvector.h:459:30: note: explicitly cast the pointer to silence this warning ::memcpy(dst, srcBegin, (srcEnd - srcBegin) * sizeof(T)); ^ (void*) QImage inherits from QPaintDevice, which has virtual functions. qimage.h declares QImage as a movable type, so QTypeInfo<QImage>::isStatic is false. Hence, the memcpy codepath will be reached when the vector is not shared. We should trust that people declaring such type traits know what they're doing, so silence the warning. Change-Id: If36582f57a398fc237fb4bd4f72938fb09667118 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Don't operate on bogus data, assert on preconditions insteadJoão Abecasis2012-06-231-5/+6
| | | | | | | | | | | | | | | | | | | | | | QVector::erase shouldn't try to make sense of iterators it doesn't own, so the validation being done here is bogus and dangerous. Instead, it's preferrable to assert, the user needs to ensure proper ownership. The case of erasing an empty sequence is not checked for preconditions to allow QVector v; v.erase(v.begin(), v.end()); , while being stricter on other uses. Autotests were using ill-formed calls to the single argument erase() function on an empty vector and were fixed. This function erases exactly one element, the one pointed to by abegin and require the element exist and be valid. Change-Id: I5f1a6d0d8da072eae0c73a3012620c4ce1065cf0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Rename QVector::realloc and QVector::free.Jędrzej Nowacki2012-06-051-13/+13
| | | | | | | | These names were confusing and conflicting with standard C memory management functions. Change-Id: I6efe20665d2ec7ad3e00f3a806cc1843a57374d4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix the QVector build with C++11 initialiser listsThiago Macieira2012-06-011-3/+3
| | | | | | | | | | | | Initialiser lists were not tested before in the QVector rewrite, so the older malloc call was left behind. Also, std::initializer_list has const iterators returning const data and broke the build in a few places where const qualifiers were missing. Change-Id: I3c04e58361989aa7438621cda63c7df457d7dad8 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
* Make QVector compile with QT_STRICT_ITERATORS againThiago Macieira2012-06-011-80/+13
| | | | | | | | | | | | Move the iterator classes into QArrayTypedData and add constBegin() and constEnd() to that class. I also had to add an operator T*() to the strict iterators, since there are many places that expect the iterator to behave like a pointer (including in QVector itself). Change-Id: Icc5ed56ad47b013664a48eef9d31b5273aecb4e3 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
* Get rid of MSVC compiler warnings from QVector codeFriedemann Kleint2012-06-011-2/+10
| | | | | | | Change-Id: I39b849721f3ba790c4a9197d69ac48e98cc2f5bd Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
* Remove debugging code from QVectorJędrzej Nowacki2012-06-011-9/+1
| | | | | | | It was depending on internals of Q_ASSERT Change-Id: I3dfc0ae0438135a30961f36808dbfc3e663a5538 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Implement QVector with QArrayData interface.Jędrzej Nowacki2012-05-301-223/+260
| | | | | Change-Id: I109f46892aed2f6024459812d24922b12358814d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Implement the move constructor for containers.Olivier Goffart2012-05-111-0/+1
| | | | | | | | | | | | | | | This changes all the containers that uses QtPrivate::RefCount (QMap already had one), and QVariant In Qt 4.8, it was pointless to have the move constructor because we did not have quick way to re-initialize a null container. (shared_null still needed to be refcounted) But now that we have RefCount, and that the shared_null do not have reference count, we can implement a fast move constructor that do not generate code to increment the reference count. Change-Id: I2bc3c6ae96983f08aa7b1c7cb98d44a89255160b Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.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 references to QT_NO_STL from QtCoreThiago Macieira2012-04-071-4/+0
| | | | | | | | QT_NO_STL is now no longer defined, so remove the conditionals and select the STL side. Change-Id: Ieedd248ae16e5a128b4ac287f850b3ebc8fb6181 Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
* Fallback implementation of Q_ALIGNOFJoão Abecasis2012-03-231-4/+0
| | | | | | | | | | | | For all practical purposes, the fallback introduced here returns the desired value. Having a fallback enables unconditional use of Q_ALIGNOF. For compilers that provide native support for it, Q_ALIGNOF is otherwise #defined in qcompilerdetection.h. Change-Id: Ie148ca8936cbbf8b80fe87771a14797c39a9d30c Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge master into api_changesKent Hansen2012-03-191-0/+2
|\ | | | | | | | | | | | | | | Conflicts: src/corelib/tools/qvector.h tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp Change-Id: I877256e95f3788e617437f4e9661a88047f38cd6
| * 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>
* | QVector: fix initializer_list constructor implementationMarc Mutz2012-02-291-3/+11
| | | | | | | | | | | | | | | | The old implementation didn't compile. Change-Id: I9892e1fff11b3a03607c468c9091eebea7e62584 Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
* | Fix signed/unsigned mismatch warningsJoão Abecasis2012-02-271-16/+19
| | | | | | | | | | | | | | | | Introduced by the change of d->alloc to unsigned, in a1621d23. Change-Id: I9e6d7fc2efbf5228c4e59c7128b8c89cf284db24 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
* | Change QVector's in-memory data layoutJoão Abecasis2012-02-221-133/+122
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new layout matches that of QByteArrayData and QStringData, except for offset which is measured from the beginning of QVectorData, whereas in those classes it (still?) references the end of the header data. The new layout uses an extra member for storing an offset into the data, which will allow introducing QVector::fromRawData, similar to the same functionality already existing in QString and QByteArray. By not using an actual array to index array members, we also steer clear of GCC bug #43247: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43247 Change-Id: I408915aacadf616b4633bbbf5cae1fc19e415087 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'gerrit/master' into containersJoão Abecasis2012-02-211-1/+1
|\| | | | | | | | | | | | | Conflicts: src/corelib/tools/qbytearray.h Change-Id: I03b1f3e05c9b7a45130887c522fcd9b7aa387129
| * Remove usages of QT_ARCH and QT_ARCH_* from qtbaseBradley T. Hughes2012-02-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The architecture is detected at compile time based on the predefined macros from the compiler. Don't use QT_ARCH in .pro, .pri, or .prf files. The PNG_NO_ASSEMBLER_CODE define from libpng.pri is not present in the current copy of src/3rdparty/libpng, so no change in functionality is expected. The conditional for the SUPPORT_JIT define in pcre.pri is moved to src/3rdparty/pcre/config.h, again so that we can use the compiler's predefined macros to detect the architecture at compile time. Replace QT_ARCH_ARM, QT_ARCH_MIPS, and QT_ARCH_SPARC with their Q_PROCESSOR_* equivalents. Replace QT_ARCH_INTEGRITY, QT_ARCH_VXWORKS, and QT_ARCH_WINDOWSCE with their Q_OS_* equivalents. Note that this commit also effectively disables the SPARC atomic implementation. An inline implementation for SPARC needs to be added, or we remove the current code and instead rely on the GCC intrinsic or C++11 std::atomic support on SPARC. Note also that this commit does not remove QT_ARCH from configure or qconfig.h. This will continue to be set until all Qt 5 projects can be moved away from using QT_ARCH. Change-Id: I5de747cc4436d21941329974cff3016970f497b8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* | Have QVectorData::grow, take size of header w/ paddingJoão Abecasis2012-02-201-15/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This includes padding necessary to align the data array, but excludes the first element as was done before. Size of header is the interesting piece of information, anyway. This simplifies calculations in a couple of places, harmonizes code with the QRawVector fork and paves the way for further changes in QVector, namely the memory layout. When Q_ALIGNOF is not available, default to pointer-size alignment. This should be honoured by malloc and won't trigger use of more expensive aligned allocation. Change-Id: I504022ac7595f69089cafd96e47a91b874d5771e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>