Speed up construction of basic QVariants
authorHarald Fernengel <harald.fernengel@nokia.com>
Tue, 14 Aug 2012 11:15:11 +0000 (13:15 +0200)
committerQt by Nokia <qt-info@nokia.com>
Wed, 15 Aug 2012 07:17:35 +0000 (09:17 +0200)
commit17adbb232bfc8972ba54cbea3be9dbb24d9b4dfc
tree088e92af5575b91d94ec852d4adce7aa81871040
parent4350054ab86b03b2a4e6641238b762fd80a3c5dd
Speed up construction of basic QVariants

Instead of first creating an initialized Private struct, then overwrite
the member variables, we added an internal constructor that
initializes the private struct sanely.

In the new (inlined, internal) constructor, both the MSB bits in the
bitfield are 0, and since the value of internal meta-type ID is so
low that the two MSB bits should never be set, the compiler can
(hopefully) optimize away the bit-fiddling initialization of the bit-field.

Callgrind shows about 33% speed-up in e.g. QVariant::QVariant(int)

Change-Id: I706773a71c0d8dcbe119ad15411578b81892deb5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
src/corelib/kernel/qvariant.cpp
src/corelib/kernel/qvariant.h