From a587022643028e23cddee5ae6dd84352d8baad83 Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Thu, 11 May 2017 00:38:57 -0700 Subject: [PATCH] Fix some more operator< implementations. This may fix some of the IndexUpdate diff issues. --- src/indexer.h | 4 +++- src/position.cc | 4 +++- src/query.h | 14 +++++++++----- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/indexer.h b/src/indexer.h index acd6f4e0..7441cb78 100644 --- a/src/indexer.h +++ b/src/indexer.h @@ -88,7 +88,9 @@ struct Ref { } bool operator!=(const Ref& other) { return !(*this == other); } bool operator<(const Ref& other) const { - return id_ < other.id && loc < other.loc; + if (id_ < other.id) + return true; + return id_ == other.id && loc < other.loc; } }; diff --git a/src/position.cc b/src/position.cc index f729dbe7..803e4f6b 100644 --- a/src/position.cc +++ b/src/position.cc @@ -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 start < that.start;// || end < that.end; + if (start < that.start) + return true; + return start == that.start && end < that.end; } \ No newline at end of file diff --git a/src/query.h b/src/query.h index 8be69f27..b18f85fc 100644 --- a/src/query.h +++ b/src/query.h @@ -53,9 +53,9 @@ struct QueryLocation { } bool operator!=(const QueryLocation& other) const { return !(*this == other); } bool operator<(const QueryLocation& o) const { - return - path < o.path && - range < o.range; + if (path < o.path) + return true; + 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 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 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; } };