From 7ecd65e1afc2ab193c01211a5feb6f97fa305d25 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 14 Mar 2016 13:38:46 +0000 Subject: [PATCH] Code cleanups --- src/commands.cc | 2 +- src/insert_completer.cc | 18 +++++------------- src/json_ui.hh | 2 +- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/commands.cc b/src/commands.cc index b376f081..8eb676ba 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -61,7 +61,7 @@ static CandidateList complete_buffer_name(StringView query, ByteCount cursor_pos { struct RankedMatchAndBuffer : RankedMatch { - RankedMatchAndBuffer(const RankedMatch& m, const Buffer* b = nullptr) + RankedMatchAndBuffer(const RankedMatch& m, const Buffer* b) : RankedMatch{m}, buffer{b} {} using RankedMatch::operator==; diff --git a/src/insert_completer.cc b/src/insert_completer.cc index c33673e6..5fa34c72 100644 --- a/src/insert_completer.cc +++ b/src/insert_completer.cc @@ -97,7 +97,7 @@ InsertCompletion complete_word(const Buffer& buffer, ByteCoord cursor_pos, const struct RankedMatchAndBuffer : RankedMatch { - RankedMatchAndBuffer(const RankedMatch& m, const Buffer* b = nullptr) + RankedMatchAndBuffer(const RankedMatch& m, const Buffer* b) : RankedMatch{m}, buffer{b} {} using RankedMatch::operator==; @@ -130,18 +130,10 @@ InsertCompletion complete_word(const Buffer& buffer, ByteCoord cursor_pos, const } } - { - using StaticWords = Vector; - const StaticWords& static_words = options["static_words"].get(); - - for (auto& word : static_words) - { - if (prefix.empty()) - matches.push_back(RankedMatch{word, prefix}); - else if (RankedMatch match{word, prefix}) - matches.push_back(match); - } - } + using StaticWords = Vector; + for (auto& word : options["static_words"].get()) + if (RankedMatch match{word, prefix}) + matches.emplace_back(match, nullptr); unordered_erase(matches, StringView{prefix}); std::sort(matches.begin(), matches.end()); diff --git a/src/json_ui.hh b/src/json_ui.hh index 563ff997..3ebbafbb 100644 --- a/src/json_ui.hh +++ b/src/json_ui.hh @@ -8,7 +8,7 @@ namespace Kakoune { -class Value; +struct Value; class JsonUI : public UserInterface {