summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qhash.h
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/5.9' into devOswald Buddenhagen2017-08-021-1/+15
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/platforms/xcb/qxcbconnection.h src/plugins/platforms/xcb/qxcbconnection_xi2.cpp src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp src/plugins/styles/mac/qmacstyle_mac.mm src/widgets/widgets/qdockarealayout.cpp src/widgets/widgets/qmainwindow.cpp src/widgets/widgets/qmainwindowlayout.cpp src/widgets/widgets/qmainwindowlayout_p.h tests/auto/corelib/tools/qlocale/tst_qlocale.cpp tests/auto/other/macnativeevents/BLACKLIST tests/auto/widgets/widgets/qmenu/BLACKLIST Change-Id: Ic8e724b80a65e7b1af25511b0e674d209265e567
| * QHash: make MSVC happy about the iterators passed to is_permutationGiuseppe D'Angelo2017-07-201-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MSVC warns about iterators being passed to certain Standard Library algorithms. dbd55cdaf367bdc9d6774bcb9927cbe19f18065f introduced a usa of std::is_permutation in a public header, which is causing such a warning to be emitted. To suppress the warning, Microsoft suggests to either use the 4-arg std::is_permutation overload (which however is not available in MSVC 2013) or to use a Standard Library extension, which we are already using elsewhere in Qt to deal with the same problem. However, that extension requires the iterator to be moved by size_t quantities, which isn't the case for QHash::iterator, and therefore generates more warnings about loss of precision (size_t -> int). Therefore, go with the 4-arg std::is_permutation, only on MSVC >= 2015. Change-Id: Idfcff28d14e0f1fde5d77f1deb9eec27c87ff5cd Task-number: QTBUG-61902 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.9' into devSimon Hausmann2017-07-191-3/+3
|\| | | | | | | | | | | | | | | Conflicts: src/corelib/io/qwindowspipewriter.cpp src/widgets/styles/qcommonstyle.cpp Change-Id: I0d33efdc4dc256e234abc490a18ccda72cd1d9e6
| * Add missing constexpr specifier to two iteratorsMårten Nordheim2017-07-141-3/+3
| | | | | | | | | | | | | | | | | | | | | | The classes themselves and their equality operators are used in constexpr functions/ctors (in QKeyValueIterator) so Visual Studio 2017 expects them to be marked constexpr as well. Currently this causes a compilation error when instantiating a QKeyValueIterator using either of these iterators. Change-Id: I2e3eeaf3b3f11f381a63875e6575dfd82fe56fcb Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Qt containers: use std::move in take*() methodsMarc Mutz2017-05-231-1/+1
| | | | | | | | | | | | | | Move the objects out of the data structure to avoid needless copies. Change-Id: I1a69fccc431e040b229d6ea9ded0e041c208c861 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-05-071-10/+18
|\| | | | | | | | | | | | | | | Conflicts: src/network/access/qnetworkreply.cpp tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp Change-Id: Iadf766269454087e69fb216fc3857d85b0ddfaad
| * QHash/QMultiHash: fix operator==Giuseppe D'Angelo2017-05-051-10/+18
| | | | | | | | | | | | | | | | | | | | | | The existing QHash::operator== does not work when the same keys appear in different order between the two hashes being compared. However, relying on iteration order on a QHash is (as usual) a bad idea and one should never do it. Task-number: QTBUG-60395 Change-Id: Ifb39a6779230e26bbd6fdba82ccc0247b9cdc6ed Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Implement key-value iteratorSamuel Gaist2017-05-051-0/+9
|/ | | | | | | | | | | | | This patch implements an iterator that returns a pair containing both the key and the value of an entry in QHash/QMap. [ChangeLog][QtCore][Containers] Added an stl-like iterator to go through QHash/QMap returning both the key and the value of the element pointed to. That lets QHash/QMap interoperate better with stl's algorithms like std::set_union. Change-Id: Idbf8a8581510b3493648c34ab04c556de9fa4aa7 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QMap, QHash: make key_iterator satisfy the DefaultConstructible conceptAnton Kudryavtsev2017-03-201-0/+1
| | | | | Change-Id: Ifc3f481ddb902b26c217516412c93a4a39a32b1c Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Remove a few unnecessary recalculations of hashAllan Sandfeld Jensen2016-11-091-4/+3
| | | | | | | | | | | When we already have the hash-value we can give it to findNode to avoid recalculating it, and if don't need it later, we don't need to request it. Removes around 1% of qHash calls when running QtCreator. Change-Id: I0e5e61e26a407f4ac7e029a3ac13ddd553e4994b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace custom type traits with std one'sKai Koehne2016-11-081-1/+1
| | | | | | | | | | | | | | | | | | Remove most type traits from qtypetraits.h, but keep the custom implementation of is_signed/is_unsigned. This gets rid of BSD-3 licensed code from Google in a public header (hugh!). The custom implementations for is_signed/is_unsigned are kept because the implementations in gcc's standard headers do not work as we expect for enums - both is_signed and is_unsigned always returns false there - see also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59027 [ChangeLog][QtCore][General] Qt now relies on type traits from the C++ standard library. Change-Id: I3f2188b46949f04ca4482a6ac9afd3482103f0e1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add qHash(QHash) and qHash(QMultiHash)Marc Mutz2016-07-141-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | The hash function is carefully designed to give the same result as the straight-forward implementation of qHash(unordered_map), which we'll probably add at some point, namely: std::accumulate over a container of std::pair. This is one reason to use std:: and not QPair in the implemen- tation of qHash(QHash). The other is that qHash(QPair) uses a bad hash combiner, which may xor out the 'seed' from the result. We can't fix that until Qt 6, but the qHash(std::pair) overload uses the well-known boost::hash_combine algorithm (implemented in Qt as QtPrivate::QHashCombine), so we can use that. I also trust std::pair to work without problems with reference template arguments, while QPair only very recently gained a very basic auto-test for reference parameters. [ChangeLog][QtCore] Added qHash() overloads for QHash, QMultiHash. Change-Id: I90879d8a99cf1aadb6e84ecc0c3704f52f3691da Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-05-191-4/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: configure src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp src/network/access/qnetworkaccessmanager.cpp src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.h src/widgets/widgets/qlineedit_p.cpp src/widgets/widgets/qlineedit_p.h src/winmain/winmain.pro tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h tests/auto/testlib/selftests/expected_cmptest.teamcity tests/auto/testlib/selftests/expected_cmptest.txt tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp tools/configure/configureapp.cpp Change-Id: Ib9997b0d0f91946e4081d36c0c6b696c5c983b2a
| * Move q{Set,}GlobalQHashSeed() to the correct header fileMarc Mutz2016-05-131-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The <QHash> only contains the container these days, while <QHashFunctions> contains the qHash() function overloads and related functions. This is where these two functions belong, too. This change is BC and SC, since qhash.h includes qhashfunctions.h. Change-Id: I2e7febb0ffca209af67fb9f2cd363596867a44e1 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * Fix Clang -Wexpansion-to-defined warning by deprecating QT_SUPPORTSThiago Macieira2016-05-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The C and C++ standards say it's undefined whether the preprocessor supports macros that expand to defined() will operate as an ifdef. Clang 3.9 started complaining about that fact. One solution was to change QT_SUPPORTS to check for zero or one, which means we need to change the #defines QT_NO_xxx to #define QT_NO_xxx 1. The C standard says we don't need to #define to 0, as an unknown token is interpreted as zero. However, that might produce a warning (GCC with -Wundef), so changing the macro this way is not recommended. Instead, we deprecate the macro and replace the uses with #ifdef/ndef. Change-Id: Id75834dab9ed466e94c7ffff1444874d5680b96a Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Add an early-out to QVector::operator+= and QHash::unite for empty LHSUlf Hermann2016-04-281-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | If the container being added to is default constructed and has never been modified, we don't have to do all the checking and iterating. Instead we can just assign with operator=. If the LHS is merely empty, we could lose reserve()d capacity, so only do this for a shared-null LHS. Change-Id: If1e3342662d10833babc7ab847ada0285073723b Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* | Introduce QHash::equal_range()Sérgio Martins2016-02-141-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | Similar to QMap::equal_range(). Will allow to easily fix inefficient code such as: foreach (auto value, hash.values(key)) { ... } [ChangeLog][QtCore][QHash] Added QHash::equal_range() Change-Id: I6e19e25de632e897ad83d3141d9d07f0313f7200 Reviewed-by: Marc Mutz <marc.mutz@kdab.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>
* | QHash/QSet: add erase(const_iterator)Marc Mutz2015-12-191-10/+17
|/ | | | | | | | | | | | This is the signature the functions have in C++11. For the std containers, this is just convenience, but for Qt containers with their implicit sharing problem, the combination of erase() with constFind() can delay a detach until absolutely necessary. [ChangeLog][QtCore][QHash/QSet] Added erase(const_iterator). Change-Id: I2fc841c664cd7515b0f56fd7210fcd17c37f9014 Reviewed-by: David Faure <david.faure@kdab.com>
* Make container move semantics consistentMarc Mutz2015-10-071-2/+2
| | | | | | | | | | | | | | | Make all containers (excepting QVarLengthArray) - nothrow default-constructible - nothrow move-constructible - nothrow move-assignable - nothrow swappable [ChangeLog][QtCore] All containers (with the exception of QVarLengthArray, but including QSharedPointer) are now nothrow_default_constructible, nothrow_move_constructible, nothrow_move_assignable, and nothrow-swappable. Change-Id: I12138d262f9f7f600f0e1218137da208c12e7c0a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMulti(Map|Hash): add move ctor from Q(Map|Hash)Marc Mutz2015-10-071-0/+3
| | | | | | | There was a copy ctor, a move ctor was missing. Change-Id: If09a4d4c74682169759eff43b298f6c77702c169 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Add getter and setter for qt_qhash_seedGabriel de Dietrich2015-09-221-0/+3
| | | | | | | | | | | | | | | | | | In some cases it's not possible to use QT_HASH_SEED, specially when we need to set the environment variable from inside the application, as dynamically loaded libraries or plugins may create static QHash instances. That would set qt_qhash_seed to a value different from -1 and skip the env var value. For those cases, and when we still want to set qt_qhash_seed, we provide a way to enforce its value. Auto-tests accessing qt_qhash_seed directly have been updated accordingly. Usage in qdoc, uic and rcc has been left as is for the time being. Change-Id: I3b35b4fa0223c83b1348a6508641905a2a63266f Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Introduce QHash key iteratorsSérgio Martins2015-07-281-0/+28
| | | | | | | | | | | So we can have interoperability with algorithms. Motivated by inefficient code like qDeleteAll(hash.keys()) [ChangeLog][QtCore][QHash] Added key iterators, accessible through keyBegin() and keyEnd(). Change-Id: I1f9db8a7a4294e1556cbb50b8fe5ebdcf0dc29a2 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* QSet/QQueue/QStack: use compiler-generated special member functionsMarc Mutz2015-07-191-0/+3
| | | | | | | | They do the right thing (except move special member functions on MSVC, but that's MSVC's problem). Change-Id: I699e1be83c0568821f8c6b84394a2713bb22e8e7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Containers: destroy previous state on move-assignment immediatelyMarc Mutz2015-07-191-1/+1
| | | | | | | | | | | | | | | | [ChangeLog][QtCore] All generic containers (with the exception of QVarLengthArray, but including QSharedPointer) destroy the previous state as part of a move-assignment now. Previously, they would dump it into the right-hand-side object. Note that this is only true for the generic containers. Other implicitly-shared types, as well as the non-generic containers QString, QByteArray, etc. still just swap the contents with the right-hand-side object when move-assigned into, and, for performance reasons, this will not change in the forseeable future. Change-Id: I1f1c684e85400b77bd2e7fba65bde2dce6c1bdde Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtCore: Use Q_NULLPTR instead of 0 in all public headersMarc Mutz2015-07-011-4/+4
| | | | | | | | | This is in preparation of adding -Wzero-as-null-pointer-constant (or similar) to the headers check. Task-number: QTBUG-45291 Change-Id: I0cc388ef9faf45cbcf425ad0dc77db3060c104a8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QSet: Introduce intersects().Sérgio Martins2015-05-301-0/+1
| | | | | | | | | | | | The pattern "mySet.intersect(other).isEmpty()" has been spotted in the wild and in Qt codebase. intersects() is much cheaper because it bails out as soon as we find one common item and doesn't do any allocations. [ChangeLog][QtCore][QSet] Added intersects(). Change-Id: I44a350dc4cdb9deb835a23eee99fc99d6ca24c82 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* QHash: Add a findNode() overload that doesn't calculate hashSérgio Martins2015-05-301-8/+16
| | | | | | | | | Needed for QSet::intersects() for optimization purposes. No need to calculate the hash when we already have it. Change-Id: I247602bb0558ca8d1fb8333de9d5f339146c576d Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Split qHash()-related code into separate headerMarc Mutz2015-04-081-97/+1
| | | | | | | | | | | | The reduces the amount of code the compiler has to parse when all the header does is implement its own qHash(). I left the implementation in qhash.cpp, as it doesn't influence qHash*() users. Change-Id: Id320d690a33769bae78b03ccc3b08f7124123459 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@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>
* QHash: clean up class definitionMarc Mutz2015-01-101-16/+16
| | | | | | | ...by removing redundant '<Key, T>' and 'inline'. Change-Id: I9d81950c6384927633de07de511712f7274a1283 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtCore: mark some operations nothrowMarc Mutz2015-01-101-4/+4
| | | | | | | | | | | | This shotgun-surgery approach is motivated by trying to get a clean(er) build for -Wnoexcept on GCC, so it is expected that for any class touched here, there will be more operations that can be marked nothrow. But they don't show up in conditional noexcept clauses, yet, so they are deferred to some later commit. Change-Id: I0eb10d75a26c361fb22cf785399e83b434bdf233 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add qHashRange and qHashRangeCommutativeMarc Mutz2015-01-091-0/+40
| | | | | | | | | | | | | | | | | | | qHashRange() takes an (input iterator) range and hashes each element, combining the hash values using the hash combiner from Boost/N1837 with the magic number 0x9e3779b9, as described here: http://stackoverflow.com/questions/4948780/magic-number-in-boosthash-combine qHashRangeCommutative() does the same but with a cummutative combiner (unsigned addition) to create hash values that are order-independent, e.g. for hashed containers. The obvious combiner, XOR, is a bad one because it eliminates duplicate elements. Signed addition cannot be used, since signed overflow leads to undefined behavior. [ChangeLog][QtCore] Added qHashRange() and qHashRangeCommutative() functions to aid implementing qHash() overloads for custom types. Change-Id: I3c2bbc9ce4bd0455262a70e0cf248486525e534f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove workarounds for RVCT compiler bugsThiago Macieira2015-01-061-18/+0
| | | | | | | | | | | | | | | This does not try to remove support for RVCT. There has been no report of it working or failing to work, so the status continues to be unknown. In particular, the inline assembly code in atomic_armv[56].h remains in place. This commit only removes workarounds for compiler bugs or bogus warnings, assuming that anyone using this compiler has updated since Qt last tried to use it for Symbian in 2011. Note also how anonymous unions are now part of the language in C++11. Change-Id: Idc4fab092beb31239eb08b7e139bce2602adae81 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Remove Q_NO_USING_KEYWORDThiago Macieira2014-12-201-1/+1
| | | | | | | | | | | | | | | | | | | There's a lot of code now requiring it. Any compiler that doesn't support the keyword is too old for Qt now. The last time anyone asked about this macro was for QTBUG-27393 and we don't know which compiler that was. As a necessity, this patch contains a reversal of a0c3a57aed5cde37017733e7cf5e41cc6a1174aa [ChangeLog][Compiler Specific Changes] Qt 5.5 now unconditionally uses the "using" keyword. Compilers that do not support this keyword are deprecated and will not be able to build Qt. Previous versions of Qt may or may not compile, as no testing was done to ensure it worked. Change-Id: Ief042f34aba555a095d1f342a0ee7ee9feadf42d Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@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>
* Remove QHashDummyNode and avoid undifined behaviorOlivier Goffart2014-07-081-25/+16
| | | | | | | | | | | | | A lot of code in QHash is doing casting to QHashNode while the pointer may be of type QHashDummyNode. This is a lot of undefined behavior. Remove QHashDummyNode and specialize QHashNode for QHashDummyValue instead. QHashDummyValue is the only type for which QTypeInfo::isDummy is true. Q_DUMMY and QTypeInfo::isDummy are internal API, so is QHashDummyNode, so we can remove them. Task-number: QTBUG-40029 Change-Id: I60c2ff0933075b9202bde89a9992746052f75133 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2014-05-061-0/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | 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-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 remote-tracking branch 'origin/stable' into devFrederik Gladhorn2014-03-241-8/+16
|\| | | | | | | | | | | | | Conflicts: src/gui/image/qjpeghandler.cpp Change-Id: I9db3acea7d5c82f5da679c8eaeb29431136665f0
| * Remove level 4 compiler warnings from MSVC.David Schulz2014-03-151-8/+16
| | | | | | | | | | | | | | | | | | | | 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
* | Make qHash(QChar) constexprGiuseppe D'Angelo2014-03-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | The signature needs a small change -- from qHash(QChar, uint) to qHash(const QChar, uint). The reason is that we need to select the const (and constexpr) overload of QChar::unicode in the body. Apart from this, it shouldn't have any effect on user code. Change-Id: I38f4f66a715111c7472e3d7def75a6cff7030919 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* | Make qHash(long) constexprGiuseppe D'Angelo2014-03-141-7/+5
| | | | | | | | | | | | | | | | By removing the if and switching to a ternary operator. Change-Id: I754c312ef06cb1e029de8e6cc562de8b12c88fc4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* | Fix the qHash(quint64) overloadGiuseppe D'Angelo2014-03-141-7/+3
| | | | | | | | | | | | | | | | | | | | | | The body doesn't make sense as the if condition is always true (we even have static asserts checking that sizeof(int) == 4). Removing the if allows us to mark the function as constexpr. Change-Id: Iddeb042a6164d4afe6c827c10177596424d770eb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* | Mark some qHash overloads as constexpr / const / pureGiuseppe D'Angelo2014-03-131-24/+24
| | | | | | | | | | | | | | | | | | | | Depending on whether the arguments are enough (f.i. arithmetic types) or they actually need to walk through memory. There are still a few which can't be marked constexpr due their body, but they'll be fixed in subsequent commits. Change-Id: I8e2bc395b8e7ae93a306d0ff8752c595e05abaf1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Add qHashBits(), a hash function for a memory blockMarc Mutz2014-02-281-0/+2
| | | | | | | | | | | | | | | | | | | | | | The function arguments have been chosen to avoid caller-side casting of argument types, when passing object addresses and type sizeof()s. [ChangeLog][QtCore] Added qHashBits() to aid implementing qHash() overloads for custom types. Change-Id: I983a8560769bb27e489f23ebb6db51850ddd65f2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QtCore: Fix MSVC 64bit warnings about conversion from size_t to int.Friedemann Kleint2014-02-251-2/+2
|/ | | | | | | warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data Change-Id: I9be380cbb7bed4cd95515074c7cad7e41a511dc9 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Add qHash() overloads for floating-point typesMarc Mutz2014-02-161-0/+5
| | | | | | | | | | | | | | | | | | | | | This implementation is based on GCC's implementation of std::hash<FP>, but only to the extent of checking for zero before hashing the bits. The bit hasher is the Qt one; I didn't even look what GCC uses. The check against 0.0 is mandated by the requirement to have \forall x,y: x == y => qHash(x) == qHash(y) which would be violated for x = 0.0 and y = -0.0 if we only hashed the bits. Implemented out-of-line to avoid potential FP-comparison warnings, as well as to be able to use the file-static hash() functions, which gets inlined unlike qHashBits(), which cannot be. [ChangeLog][QtCore][QHash/QSet] Allowed to use float, double and long double as QHash/QSet keys. Change-Id: I38cec4afb860f17e9f8be7b67544e58b330f8fff Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Don't compare const_iterator with iterator.Stephen Kelly2013-08-271-2/+2
| | | | | | | | | Commit 93ffb81df6e2cdc57ac8f70c6578f132024d7117 introduced this bug. As it is in the header, it affects downstreams. Change-Id: I02e86927e648153ca7c0b66ac945a7f99cc4cd89 Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QHash/QSet - fix QHash::erase when the hash is sharedThorbjørn Martsum2013-08-241-0/+16
| | | | | | | | | | | | | Before a call to erase on a shared instance would imply that the item was removed from the shared data (i.e all instances) This patch improves the behavior to detach and erase the item specified by the iterator (i.e same behavior as QVector) Since QSet uses QHash it improves QSet the same way. Change-Id: I850b1efcf7bdfc85ceddb23128b048af95f75063 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>