From 714e14fe61ebd1d1a97599b429cbbb0a54bbe6c4 Mon Sep 17 00:00:00 2001 From: David Brazdil Date: Wed, 25 Feb 2015 11:57:05 +0000 Subject: [PATCH] ART: Nano optimization of LiveInterval Shuffling the order of conditions in the FirstIntersectionWith method of LiveInterval class can save a couple of comparisons. Even though this is a tiny optimization, it can save some compilation time since the method is heavily used during register allocation. Change-Id: I1817bd95db2d0eb96cc06fb2e9e06ac1cea784fe --- compiler/optimizing/ssa_liveness_analysis.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/optimizing/ssa_liveness_analysis.h b/compiler/optimizing/ssa_liveness_analysis.h index be7262945..45b433f4c 100644 --- a/compiler/optimizing/ssa_liveness_analysis.h +++ b/compiler/optimizing/ssa_liveness_analysis.h @@ -345,19 +345,19 @@ class LiveInterval : public ArenaObject { LiveRange* my_range = first_range_; LiveRange* other_range = other->first_range_; do { - if (my_range->IntersectsWith(*other_range)) { - return std::max(my_range->GetStart(), other_range->GetStart()); - } else if (my_range->IsBefore(*other_range)) { + if (my_range->IsBefore(*other_range)) { my_range = my_range->GetNext(); if (my_range == nullptr) { return kNoLifetime; } - } else { - DCHECK(other_range->IsBefore(*my_range)); + } else if (other_range->IsBefore(*my_range)) { other_range = other_range->GetNext(); if (other_range == nullptr) { return kNoLifetime; } + } else { + DCHECK(my_range->IntersectsWith(*other_range)); + return std::max(my_range->GetStart(), other_range->GetStart()); } } while (true); } -- 2.11.0