mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1166836: Part3. Optimise most common addition to IntervalSet. r=mattwoodrow
This commit is contained in:
parent
70c9952e4a
commit
b37bb7571f
@ -212,6 +212,15 @@ public:
|
||||
mFuzz = aFuzz;
|
||||
}
|
||||
|
||||
// Returns true if the two intervals intersect with this being on the right
|
||||
// of aOther
|
||||
bool TouchesOnRight(const SelfType& aOther) const
|
||||
{
|
||||
return aOther.mStart <= mStart &&
|
||||
(mStart - mFuzz <= aOther.mEnd + aOther.mFuzz) &&
|
||||
(aOther.mStart - aOther.mFuzz <= mEnd + mFuzz);
|
||||
}
|
||||
|
||||
T mStart;
|
||||
T mEnd;
|
||||
T mFuzz;
|
||||
@ -305,10 +314,14 @@ public:
|
||||
mIntervals.AppendElement(aInterval);
|
||||
return *this;
|
||||
}
|
||||
ElemType& last = mIntervals.LastElement();
|
||||
if (aInterval.TouchesOnRight(last)) {
|
||||
last = last.Span(aInterval);
|
||||
return *this;
|
||||
}
|
||||
// Most of our actual usage is adding an interval that will be outside the
|
||||
// range. We can speed up normalization here.
|
||||
if (aInterval.RightOf(mIntervals.LastElement()) &&
|
||||
!aInterval.Touches(mIntervals.LastElement())) {
|
||||
if (aInterval.RightOf(last)) {
|
||||
mIntervals.AppendElement(aInterval);
|
||||
return *this;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user