bool operator==(Change const & l, Change const & r)
{
- return l.type == r.type &&
- l.author == r.author &&
+ if (l.type != r.type) {
+ return false;
+ }
+
+ // two changes of type UNCHANGED are always equal
+ if (l.type == Change::UNCHANGED) {
+ return true;
+ }
+
+ return l.author == r.author &&
l.changetime == r.changetime;
}
}
-bool Changes::Range::contains(Range const & r) const
-{
- return r.start >= start && r.end <= end;
-}
-
-
-bool Changes::Range::contains(pos_type const pos) const
-{
- return pos >= start && pos < end;
-}
-
-
bool Changes::Range::intersects(Range const & r) const
{
return r.start < end && r.end > start; // end itself is not in the range!
}
-Change const Changes::lookup(pos_type const pos) const
+Change const & Changes::lookup(pos_type const pos) const
{
- if (table_.empty()) {
- return Change(Change::UNCHANGED);
- }
+ static Change const noChange = Change(Change::UNCHANGED);
+
ChangeTable::const_iterator it = table_.begin();
ChangeTable::const_iterator const end = table_.end();
return it->change;
}
- return Change(Change::UNCHANGED);
+ return noChange;
}