Merge lp:~aacid/qtmir/unlikelyResetStartTime into lp:qtmir

Proposed by Albert Astals Cid
Status: Merged
Approved by: Gerry Boland
Approved revision: 431
Merged at revision: 446
Proposed branch: lp:~aacid/qtmir/unlikelyResetStartTime
Merge into: lp:qtmir
Prerequisite: lp:~aacid/qtmir/timestampsInPast
Diff against target: 16 lines (+3/-3)
1 file modified
src/common/timestamp_impl.h (+3/-3)
To merge this branch: bzr merge lp:~aacid/qtmir/unlikelyResetStartTime
Reviewer Review Type Date Requested Status
Gerry Boland (community) Approve
Albert Astals Cid Pending
Review via email: mp+281843@code.launchpad.net

This proposal supersedes a proposal from 2015-12-15.

Commit message

Provide branch prediction information to the if in compressTimestamp

Description of the change

 * Are there any related MPs required for this MP to build/function as expected?
Prerequisite

 * Did you perform an exploratory manual test run of your code change and any related functionality?
Yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A

To post a comment you must log in.
Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

This seems a pretty hot path and 99.999% of the times the if evaluates to false so i thought it might make sense telling the compiler to optimize for that.

Revision history for this message
Gerry Boland (gerboland) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Gerry Boland (gerboland) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/common/timestamp_impl.h'
--- src/common/timestamp_impl.h 2016-01-07 11:43:03 +0000
+++ src/common/timestamp_impl.h 2016-01-07 11:43:03 +0000
@@ -15,9 +15,9 @@
15{15{
16 std::chrono::nanoseconds startTime = getStartTime(timestamp);16 std::chrono::nanoseconds startTime = getStartTime(timestamp);
1717
18 if ((std::chrono::nanoseconds::max() > T::max() &&18 if (Q_UNLIKELY((std::chrono::nanoseconds::max() > T::max() &&
19 timestamp - startTime > std::chrono::nanoseconds(T::max()))19 timestamp - startTime > std::chrono::nanoseconds(T::max()))
20 || timestamp < startTime) {20 || timestamp < startTime)) {
21 // we've overflowed the boundaries of the millisecond type.21 // we've overflowed the boundaries of the millisecond type.
22 // or the timestamp has travelled to the past22 // or the timestamp has travelled to the past
23 resetStartTime(timestamp);23 resetStartTime(timestamp);

Subscribers

People subscribed via source and target branches