Fix some more operator< implementations. This may fix some of the IndexUpdate diff issues.

This commit is contained in:
Jacob Dufault 2017-05-11 00:38:57 -07:00
parent 57da6a81ab
commit a587022643
3 changed files with 15 additions and 7 deletions

View File

@ -88,7 +88,9 @@ struct Ref {
} }
bool operator!=(const Ref<T>& other) { return !(*this == other); } bool operator!=(const Ref<T>& other) { return !(*this == other); }
bool operator<(const Ref<T>& other) const { bool operator<(const Ref<T>& other) const {
return id_ < other.id && loc < other.loc; if (id_ < other.id)
return true;
return id_ == other.id && loc < other.loc;
} }
}; };

View File

@ -134,5 +134,7 @@ bool Range::operator==(const Range& that) const {
bool Range::operator!=(const Range& that) const { return !(*this == that); } bool Range::operator!=(const Range& that) const { return !(*this == that); }
bool Range::operator<(const Range& that) const { bool Range::operator<(const Range& that) const {
return start < that.start;// || end < that.end; if (start < that.start)
return true;
return start == that.start && end < that.end;
} }

View File

@ -53,9 +53,9 @@ struct QueryLocation {
} }
bool operator!=(const QueryLocation& other) const { return !(*this == other); } bool operator!=(const QueryLocation& other) const { return !(*this == other); }
bool operator<(const QueryLocation& o) const { bool operator<(const QueryLocation& o) const {
return if (path < o.path)
path < o.path && return true;
range < o.range; return path == o.path && range < o.range;
} }
}; };
@ -72,7 +72,9 @@ struct SymbolIdx {
} }
bool operator!=(const SymbolIdx& that) const { return !(*this == that); } bool operator!=(const SymbolIdx& that) const { return !(*this == that); }
bool operator<(const SymbolIdx& that) const { bool operator<(const SymbolIdx& that) const {
return kind < that.kind || idx < that.idx; if (kind < that.kind)
return true;
return kind == that.kind && idx < that.idx;
} }
}; };
@ -87,7 +89,9 @@ struct SymbolRef {
} }
bool operator!=(const SymbolRef& that) const { return !(*this == that); } bool operator!=(const SymbolRef& that) const { return !(*this == that); }
bool operator<(const SymbolRef& that) const { bool operator<(const SymbolRef& that) const {
return idx < that.idx && loc.range.start < that.loc.range.start; if (idx < that.idx)
return true;
return idx == that.idx && loc.range.start < that.loc.range.start;
} }
}; };