Skip to content

Commit

Permalink
const-correct
Browse files Browse the repository at this point in the history
  • Loading branch information
Andersbakken committed Apr 11, 2016
1 parent b46fcda commit 6ce017f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/CompletionThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ static inline bool isPartOfSymbol(char ch)
return isalnum(ch) || ch == '_';
}

bool CompletionThread::compareCompletionCandidates(Completions::Candidate *l,
Completions::Candidate *r)
bool CompletionThread::compareCompletionCandidates(const Completions::Candidate *l,
const Completions::Candidate *r)
{
if (l->priority != r->priority)
return l->priority < r->priority;
Expand Down Expand Up @@ -414,9 +414,10 @@ void CompletionThread::process(Request *request)
}
if (nodeCount) {
// Sort pointers instead of shuffling candidates around
std::vector<Completions::Candidate*> nodesPtr;
std::vector<const Completions::Candidate*> nodesPtr;
nodesPtr.reserve(nodeCount);
for (auto& n : nodes) nodesPtr.push_back(&n);
for (const auto &n : nodes)
nodesPtr.push_back(&n);

std::sort(nodesPtr.begin(), nodesPtr.end(), compareCompletionCandidates);

Expand Down
4 changes: 2 additions & 2 deletions src/CompletionThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ class CompletionThread : public Thread
};

void printCompletions(const List<Completions::Candidate> &completions, Request *request);
static bool compareCompletionCandidates(Completions::Candidate *l,
Completions::Candidate *r);
static bool compareCompletionCandidates(const Completions::Candidate *l,
const Completions::Candidate *r);

struct SourceFile {
SourceFile()
Expand Down

0 comments on commit 6ce017f

Please sign in to comment.