From 6fa92f79686d059c7bfc88d02923a065fc004d55 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Mon, 1 Jan 2018 12:36:08 -0800 Subject: [PATCH] Compare hover & comments in {Func,Type,Var}DefDefinitionData::operator== So that the changes populate to querydb. Also expand two std::set_difference calls to save one scan --- src/indexer.h | 9 ++++++--- src/query.cc | 21 +++++++++++++++------ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/indexer.h b/src/indexer.h index 54ff8c42..466c29b1 100644 --- a/src/indexer.h +++ b/src/indexer.h @@ -183,7 +183,8 @@ struct TypeDefDefinitionData { definition_spelling == other.definition_spelling && definition_extent == other.definition_extent && alias_of == other.alias_of && parents == other.parents && - types == other.types && funcs == other.funcs && vars == other.vars; + types == other.types && funcs == other.funcs && vars == other.vars && + hover == other.hover && comments == other.comments; } bool operator!=( @@ -276,7 +277,8 @@ struct FuncDefDefinitionData { definition_spelling == other.definition_spelling && definition_extent == other.definition_extent && declaring_type == other.declaring_type && base == other.base && - locals == other.locals && callees == other.callees; + locals == other.locals && callees == other.callees && + hover == other.hover && comments == other.comments; } bool operator!=( const FuncDefDefinitionData& other) @@ -405,7 +407,8 @@ struct VarDefDefinitionData { definition_spelling == other.definition_spelling && definition_extent == other.definition_extent && variable_type == other.variable_type && - declaring_type == other.declaring_type; + declaring_type == other.declaring_type && hover == other.hover && + comments == other.comments; } bool operator!=( const VarDefDefinitionData& other) const { diff --git a/src/query.cc b/src/query.cc index 146556fd..4b867cb1 100644 --- a/src/query.cc +++ b/src/query.cc @@ -118,12 +118,21 @@ bool ComputeDifferenceForUpdate(std::vector& previous, std::sort(previous.begin(), previous.end()); std::sort(current.begin(), current.end()); - // Returns the elements in |previous| that are not in |current|. - std::set_difference(previous.begin(), previous.end(), current.begin(), - current.end(), std::back_inserter(*removed)); - // Returns the elements in |current| that are not in |previous|. - std::set_difference(current.begin(), current.end(), previous.begin(), - previous.end(), std::back_inserter(*added)); + auto it0 = previous.begin(), it1 = current.begin(); + while (it0 != previous.end() && it1 != current.end()) { + // Elements in |previous| that are not in |current|. + if (*it0 < *it1) + removed->push_back(*it0++); + // Elements in |current| that are not in |previous|. + else if (*it1 < *it0) + added->push_back(*it1++); + else + ++it0, ++it1; + } + while (it0 != previous.end()) + removed->push_back(*it0++); + while (it1 != current.end()) + added->push_back(*it1++); return !removed->empty() || !added->empty(); }