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
diff --git a/compiler/optimizing/ssa_liveness_analysis.h b/compiler/optimizing/ssa_liveness_analysis.h
index be72629..45b433f 100644
--- a/compiler/optimizing/ssa_liveness_analysis.h
+++ b/compiler/optimizing/ssa_liveness_analysis.h
@@ -345,19 +345,19 @@
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);
}