QElapsedTimer: Instead of two ints, store only the clock type
authorThiago Macieira <thiago.macieira@intel.com>
Fri, 10 Aug 2012 14:13:23 +0000 (16:13 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Wed, 10 Oct 2012 06:45:22 +0000 (08:45 +0200)
commit66324e304969043b22fb8e5765337e28c562952e
tree03bc8b13bec1ce3f39e48d70e0c5ceebc80234de
parent4ec79a151f9007d739b0970c062eb452133be4d6
QElapsedTimer: Instead of two ints, store only the clock type

We don't need two ints if we can do it with one. We need to store only
the clock type to be used, which is either CLOCK_MONOTONIC or
CLOCK_REALTIME. In addition, we need an invalid value to indicate that
the test hasn't been done yet.

This also gets rid of an atomic that wasn't QBasicAtomicInt.

Disassembly of the compiled code indicates this is the most optimal
solution:
 - one single variable load
 - one test-and-branch to verify that a test is needed
 - straight call to clock_gettime afterwards

Change-Id: I49788e45b50b6b7fcb7ba4e9332e5352a4428933
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
src/corelib/tools/qelapsedtimer_unix.cpp