From da562e03a0126adf60d84682f5892b1f610a6ba5 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 12 Jan 2015 13:58:41 +0000 Subject: [PATCH] replace all std::vector with Vector --- src/alias_registry.cc | 4 ++-- src/alias_registry.hh | 2 +- src/buffer.cc | 6 +++--- src/buffer.hh | 9 ++++----- src/buffer_manager.hh | 2 +- src/buffer_utils.cc | 4 ++-- src/client_manager.hh | 4 ++-- src/command_manager.cc | 6 +++--- src/commands.cc | 18 +++++++++--------- src/context.cc | 6 +++--- src/context.hh | 6 +++--- src/display_buffer.hh | 7 +++---- src/event_manager.hh | 6 +++--- src/highlighters.cc | 6 +++--- src/input_handler.cc | 20 ++++++++++---------- src/input_handler.hh | 4 ++-- src/insert_completer.cc | 4 ++-- src/line_modification.cc | 4 ++-- src/line_modification.hh | 5 ++--- src/main.cc | 12 ++++++------ src/ncurses_ui.cc | 2 +- src/ncurses_ui.hh | 2 +- src/normal.cc | 36 ++++++++++++++++++------------------ src/option_types.hh | 12 ++++++------ src/register_manager.cc | 4 ++-- src/register_manager.hh | 4 ++-- src/remote.cc | 8 ++++---- src/remote.hh | 2 +- src/safe_ptr.hh | 5 ++--- src/selection.cc | 12 ++++++------ src/selection.hh | 16 ++++++++-------- src/selectors.cc | 8 ++++---- src/shell_manager.cc | 2 +- src/shell_manager.hh | 2 +- src/unit_tests.cc | 2 +- src/word_db.hh | 4 ++-- 36 files changed, 126 insertions(+), 130 deletions(-) diff --git a/src/alias_registry.cc b/src/alias_registry.cc index 95c4784b..24cd2d1b 100644 --- a/src/alias_registry.cc +++ b/src/alias_registry.cc @@ -30,9 +30,9 @@ StringView AliasRegistry::operator[](const String& alias) const return StringView{}; } -std::vector AliasRegistry::aliases_for(StringView command) const +Vector AliasRegistry::aliases_for(StringView command) const { - std::vector res; + Vector res; if (m_parent) res = m_parent->aliases_for(command); diff --git a/src/alias_registry.hh b/src/alias_registry.hh index 40acf190..1e292533 100644 --- a/src/alias_registry.hh +++ b/src/alias_registry.hh @@ -16,7 +16,7 @@ public: void remove_alias(const String& alias); StringView operator[](const String& name) const; - std::vector aliases_for(StringView command) const; + Vector aliases_for(StringView command) const; private: friend class Scope; diff --git a/src/buffer.cc b/src/buffer.cc index 71cae3de..a87c48de 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -15,7 +15,7 @@ namespace Kakoune { -Buffer::Buffer(String name, Flags flags, std::vector lines, +Buffer::Buffer(String name, Flags flags, Vector lines, time_t fs_timestamp) : Scope(GlobalScope::instance()), m_name(flags & Flags::File ? real_path(parse_filename(name)) : std::move(name)), @@ -157,7 +157,7 @@ struct Buffer::Modification } }; -void Buffer::reload(std::vector lines, time_t fs_timestamp) +void Buffer::reload(Vector lines, time_t fs_timestamp) { m_changes.push_back({ Change::Erase, {0,0}, back_coord(), true }); @@ -284,7 +284,7 @@ ByteCoord Buffer::do_insert(ByteCoord pos, StringView content) StringView prefix = m_lines[pos.line].substr(0, pos.column); StringView suffix = m_lines[pos.line].substr(pos.column); - std::vector new_lines; + Vector new_lines; ByteCount start = 0; for (ByteCount i = 0; i < content.length(); ++i) diff --git a/src/buffer.hh b/src/buffer.hh index a31062c4..f66e364f 100644 --- a/src/buffer.hh +++ b/src/buffer.hh @@ -7,8 +7,7 @@ #include "scope.hh" #include "interned_string.hh" #include "value.hh" - -#include +#include "vector.hh" namespace Kakoune { @@ -77,7 +76,7 @@ public: NoUndo = 8, }; - Buffer(String name, Flags flags, std::vector lines = { "\n" }, + Buffer(String name, Flags flags, Vector lines = { "\n" }, time_t fs_timestamp = InvalidTime); Buffer(const Buffer&) = delete; Buffer& operator= (const Buffer&) = delete; @@ -148,7 +147,7 @@ public: void run_hook_in_own_context(const String& hook_name, StringView param); - void reload(std::vector lines, time_t fs_timestamp = InvalidTime); + void reload(Vector lines, time_t fs_timestamp = InvalidTime); void check_invariant() const; @@ -187,7 +186,7 @@ private: Flags m_flags; struct Modification; - using UndoGroup = std::vector; + using UndoGroup = Vector; friend class UndoGroupOptimizer; using History = Vector; diff --git a/src/buffer_manager.hh b/src/buffer_manager.hh index 9d6edacc..8a046ff3 100644 --- a/src/buffer_manager.hh +++ b/src/buffer_manager.hh @@ -13,7 +13,7 @@ class Buffer; class BufferManager : public Singleton { public: - using BufferList = std::vector>; + using BufferList = Vector>; using iterator = BufferList::const_iterator; ~BufferManager(); diff --git a/src/buffer_utils.cc b/src/buffer_utils.cc index 10c04aa7..b3b3e936 100644 --- a/src/buffer_utils.cc +++ b/src/buffer_utils.cc @@ -39,7 +39,7 @@ Buffer* create_buffer_from_data(StringView data, StringView name, pos = data.begin() + 3; } - std::vector lines; + Vector lines; while (pos < data.end()) { const char* line_end = pos; @@ -88,7 +88,7 @@ Buffer* create_fifo_buffer(String name, int fd, bool scroll) if (buffer) { buffer->flags() |= Buffer::Flags::NoUndo; - buffer->reload(std::vector({"\n"_str}), 0); + buffer->reload(Vector({"\n"_str}), 0); } else buffer = new Buffer(std::move(name), Buffer::Flags::Fifo | Buffer::Flags::NoUndo); diff --git a/src/client_manager.hh b/src/client_manager.hh index 2de83d00..1d1147b5 100644 --- a/src/client_manager.hh +++ b/src/client_manager.hh @@ -48,8 +48,8 @@ public: private: String generate_name() const; - std::vector> m_clients; - std::vector m_free_windows; + Vector> m_clients; + Vector m_free_windows; }; } diff --git a/src/command_manager.cc b/src/command_manager.cc index 32c06199..0b9e65a2 100644 --- a/src/command_manager.cc +++ b/src/command_manager.cc @@ -70,7 +70,7 @@ private: }; -using TokenList = std::vector; +using TokenList = Vector; bool is_command_separator(char c) { @@ -402,7 +402,7 @@ void CommandManager::execute(StringView command_line, return; CharCoord command_coord; - std::vector params; + Vector params; for (auto it = tokens.begin(); it != tokens.end(); ++it) { if (params.empty()) @@ -556,7 +556,7 @@ Completions CommandManager::complete(const Context& context, not command_it->second.completer) return Completions(); - std::vector params; + Vector params; for (auto token_it = tokens.begin() + cmd_idx + 1; token_it != tokens.end(); ++token_it) params.push_back(token_it->content()); diff --git a/src/commands.cc b/src/commands.cc index c2753fca..71ecd221 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -260,7 +260,7 @@ void quit() { if (not force and ClientManager::instance().count() == 1) { - std::vector names; + Vector names; for (auto& buffer : BufferManager::instance()) { if ((buffer->flags() & Buffer::Flags::File) and buffer->is_modified()) @@ -495,7 +495,7 @@ const CommandDesc add_highlighter_cmd = { auto begin = parser.begin(); const String& name = *begin++; - std::vector highlighter_params; + Vector highlighter_params; for (; begin != parser.end(); ++begin) highlighter_params.push_back(*begin); @@ -609,9 +609,9 @@ const CommandDesc rm_hook_cmd = { } }; -std::vector params_to_shell(const ParametersParser& parser) +Vector params_to_shell(const ParametersParser& parser) { - std::vector vars; + Vector vars; for (size_t i = 0; i < parser.positional_count(); ++i) vars.push_back(parser[i]); return vars; @@ -1255,9 +1255,9 @@ const CommandDesc menu_cmd = { return; } - std::vector choices; - std::vector commands; - std::vector select_cmds; + Vector choices; + Vector commands; + Vector select_cmds; for (int i = 0; i < count; i += modulo) { choices.push_back(parser[i]); @@ -1424,14 +1424,14 @@ public: : m_name(name) { ArrayView save = RegisterManager::instance()[name].values(context); - m_save = std::vector(save.begin(), save.end()); + m_save = Vector(save.begin(), save.end()); } ~RegisterRestorer() { RegisterManager::instance()[m_name] = m_save; } private: - std::vector m_save; + Vector m_save; char m_name; }; diff --git a/src/context.cc b/src/context.cc index 84b83405..3612d7f5 100644 --- a/src/context.cc +++ b/src/context.cc @@ -202,16 +202,16 @@ const SelectionList& Context::selections() const return const_cast(*this).selections(); } -std::vector Context::selections_content() const +Vector Context::selections_content() const { auto& buf = buffer(); - std::vector contents; + Vector contents; for (auto& sel : selections()) contents.push_back(buf.string(sel.min(), buf.char_next(sel.max()))); return contents; } -void Context::set_selections(std::vector sels) +void Context::set_selections(Vector sels) { *m_selections = std::move(sels); (*m_selections).check_invariant(); diff --git a/src/context.hh b/src/context.hh index dd94fab9..bd89be27 100644 --- a/src/context.hh +++ b/src/context.hh @@ -88,8 +88,8 @@ public: SelectionList& selections(); const SelectionList& selections() const; - std::vector selections_content() const; - void set_selections(std::vector sels); + Vector selections_content() const; + void set_selections(Vector sels); void change_buffer(Buffer& buffer); @@ -147,7 +147,7 @@ private: String m_name; - using JumpList = std::vector; + using JumpList = Vector; JumpList m_jump_list; JumpList::iterator m_current_jump = m_jump_list.begin(); diff --git a/src/display_buffer.hh b/src/display_buffer.hh index 83ba7d6b..1ddb9f44 100644 --- a/src/display_buffer.hh +++ b/src/display_buffer.hh @@ -4,8 +4,7 @@ #include "face.hh" #include "coord.hh" #include "string.hh" - -#include +#include "vector.hh" namespace Kakoune { @@ -81,7 +80,7 @@ private: }; using BufferRange = std::pair; -using AtomList = std::vector; +using AtomList = Vector; class DisplayLine { @@ -127,7 +126,7 @@ private: class DisplayBuffer { public: - using LineList = std::vector; + using LineList = Vector; DisplayBuffer() {} LineList& lines() { return m_lines; } diff --git a/src/event_manager.hh b/src/event_manager.hh index b4c1f2a9..070fbff4 100644 --- a/src/event_manager.hh +++ b/src/event_manager.hh @@ -3,9 +3,9 @@ #include "utils.hh" #include "flags.hh" +#include "vector.hh" #include -#include #include #include @@ -84,8 +84,8 @@ public: private: friend class FDWatcher; friend class Timer; - std::vector m_fd_watchers; - std::vector m_timers; + Vector m_fd_watchers; + Vector m_timers; fd_set m_forced_fd; TimePoint m_last; diff --git a/src/highlighters.cc b/src/highlighters.cc index 90ea4f96..e9147f87 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -207,7 +207,7 @@ public: if (flags != HighlightFlags::Highlight) return; - std::vector> faces(m_faces.size()); + Vector> faces(m_faces.size()); auto& cache = update_cache_ifn(context.buffer(), display_buffer.range()); for (auto& match : cache.m_matches) { @@ -645,13 +645,13 @@ HighlighterAndId create_flag_lines_highlighter(HighlighterParameters params) Color bg = str_to_color(params[0]); // throw if wrong option type - GlobalScope::instance().options()[option_name].get>(); + GlobalScope::instance().options()[option_name].get>(); auto func = [=](const Context& context, HighlightFlags flags, DisplayBuffer& display_buffer, BufferRange) { auto& lines_opt = context.options()[option_name]; - auto& lines = lines_opt.get>(); + auto& lines = lines_opt.get>(); CharCount width = 0; for (auto& l : lines) diff --git a/src/input_handler.cc b/src/input_handler.cc index 2a5a1c82..afc6aecf 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -440,7 +440,7 @@ public: private: MenuCallback m_callback; - using ChoiceList = std::vector; + using ChoiceList = Vector; const ChoiceList m_choices; ChoiceList::const_iterator m_selected; @@ -476,13 +476,13 @@ String common_prefix(ArrayView strings) return res; } -void history_push(std::vector& history, StringView entry) +void history_push(Vector& history, StringView entry) { if(entry.empty()) { return; } - std::vector::iterator it; + Vector::iterator it; while ((it = find(history, entry)) != history.end()) history.erase(it); history.push_back(entry); @@ -507,7 +507,7 @@ public: void on_key(Key key) override { - std::vector& history = ms_history[m_prompt]; + Vector& history = ms_history[m_prompt]; const String& line = m_line_editor.line(); bool showcompl = false; @@ -739,10 +739,10 @@ private: bool m_autoshowcompl; Mode m_mode = Mode::Default; - static UnorderedMap> ms_history; - std::vector::iterator m_history_it; + static UnorderedMap> ms_history; + Vector::iterator m_history_it; }; -UnorderedMap> Prompt::ms_history; +UnorderedMap> Prompt::ms_history; class NextKey : public InputMode { @@ -828,7 +828,7 @@ public: } else if (key == Key::Backspace) { - std::vector sels; + Vector sels; for (auto& sel : context().selections()) { if (sel.cursor() == ByteCoord{0,0}) @@ -841,7 +841,7 @@ public: } else if (key == Key::Delete) { - std::vector sels; + Vector sels; for (auto& sel : context().selections()) sels.push_back({ sel.cursor() }); SelectionList{buffer, std::move(sels)}.erase(); @@ -1067,7 +1067,7 @@ void InputHandler::repeat_last_insert() if (m_last_insert.second.empty()) return; - std::vector keys; + Vector keys; swap(keys, m_last_insert.second); // context.last_insert will be refilled by the new Insert // this is very inefficient. diff --git a/src/input_handler.hh b/src/input_handler.hh index 637e2271..d7d831a3 100644 --- a/src/input_handler.hh +++ b/src/input_handler.hh @@ -88,11 +88,11 @@ private: friend class InputMode; std::unique_ptr m_mode; - std::vector> m_mode_trash; + Vector> m_mode_trash; void change_input_mode(InputMode* new_mode); - using Insertion = std::pair>; + using Insertion = std::pair>; Insertion m_last_insert = {InsertMode::Insert, {}}; char m_recording_reg = 0; diff --git a/src/insert_completer.cc b/src/insert_completer.cc index 62ebed6e..bcfca6dc 100644 --- a/src/insert_completer.cc +++ b/src/insert_completer.cc @@ -385,7 +385,7 @@ void InsertCompleter::menu_show() const CharCount tabstop = m_options["tabstop"].get(); const CharCount column = get_column(m_context.buffer(), tabstop, m_completions.begin); - std::vector menu_entries; + Vector menu_entries; for (auto& candidate : m_matching_candidates) menu_entries.push_back(expand_tabs(candidate.first, tabstop, column)); @@ -399,7 +399,7 @@ void InsertCompleter::menu_show() void InsertCompleter::on_option_changed(const Option& opt) { auto& completers = m_options["completers"].get(); - std::vector option_names; + Vector option_names; for (auto& completer : completers) { if (completer.mode == InsertCompleterDesc::Option) diff --git a/src/line_modification.cc b/src/line_modification.cc index 62c76243..96249856 100644 --- a/src/line_modification.cc +++ b/src/line_modification.cc @@ -42,9 +42,9 @@ struct LineChange } -std::vector compute_line_modifications(const Buffer& buffer, size_t timestamp) +Vector compute_line_modifications(const Buffer& buffer, size_t timestamp) { - std::vector res; + Vector res; for (auto& buf_change : buffer.changes_since(timestamp)) { const LineChange change(buf_change); diff --git a/src/line_modification.hh b/src/line_modification.hh index 6f825c19..d56a65d4 100644 --- a/src/line_modification.hh +++ b/src/line_modification.hh @@ -3,8 +3,7 @@ #include "units.hh" #include "utils.hh" - -#include +#include "vector.hh" namespace Kakoune { @@ -21,7 +20,7 @@ struct LineModification LineCount diff() const { return new_line - old_line + num_added - num_removed; } }; -std::vector compute_line_modifications(const Buffer& buffer, size_t timestamp); +Vector compute_line_modifications(const Buffer& buffer, size_t timestamp); } diff --git a/src/main.cc b/src/main.cc index 8c38e161..ae365cf5 100644 --- a/src/main.cc +++ b/src/main.cc @@ -144,7 +144,7 @@ void register_env_vars() void register_registers() { - using StringList = std::vector; + using StringList = Vector; static const struct { char name; StringList (*func)(const Context&); @@ -167,7 +167,7 @@ void register_registers() { register_manager.register_dynamic_register('0'+i, [i](const Context& context) { - std::vector result; + Vector result; for (auto& sel : context.selections()) result.emplace_back(i < sel.captures().size() ? sel.captures()[i] : ""); return result; @@ -210,7 +210,7 @@ void register_options() Regex{}); reg.declare_option("filetype", "buffer filetype", ""_str); reg.declare_option("path", "path to consider when trying to find a file", - std::vector({ "./", "/usr/include" })); + Vector({ "./", "/usr/include" })); reg.declare_option("completers", "insert mode completers to execute.", InsertCompleterDescList({ InsertCompleterDesc{ InsertCompleterDesc::Filename }, @@ -508,7 +508,7 @@ int main(int argc, char* argv[]) signal(SIGQUIT, signal_handler); signal(SIGTERM, signal_handler); - std::vector params; + Vector params; for (size_t i = 1; i < argc; ++i) params.push_back(argv[i]); @@ -540,7 +540,7 @@ int main(int argc, char* argv[]) } else if (parser.has_option("f")) { - std::vector files; + Vector files; for (size_t i = 0; i < parser.positional_count(); ++i) files.emplace_back(parser[i]); @@ -566,7 +566,7 @@ int main(int argc, char* argv[]) } else { - std::vector files; + Vector files; for (size_t i = 0; i < parser.positional_count(); ++i) files.emplace_back(parser[i]); StringView session; diff --git a/src/ncurses_ui.cc b/src/ncurses_ui.cc index 48ca0991..135af8f8 100644 --- a/src/ncurses_ui.cc +++ b/src/ncurses_ui.cc @@ -693,7 +693,7 @@ template static String make_info_box(StringView title, StringView message, CharCount max_width) { - static const std::vector assistant = + static const Vector assistant = { " ╭──╮ ", " │ │ ", " @ @ ╭", diff --git a/src/ncurses_ui.hh b/src/ncurses_ui.hh index dde7a59f..2cf35965 100644 --- a/src/ncurses_ui.hh +++ b/src/ncurses_ui.hh @@ -58,7 +58,7 @@ private: void update_dimensions(); NCursesWin* m_menu_win = nullptr; - std::vector m_items; + Vector m_items; Face m_menu_fg; Face m_menu_bg; int m_selected_item = 0; diff --git a/src/normal.cc b/src/normal.cc index 9ed62ba7..567badfb 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -211,7 +211,7 @@ void goto_commands(Context& context, NormalParams params) if (contains(filename, c)) return; - auto paths = context.options()["path"].get>(); + auto paths = context.options()["path"].get>(); const String& buffer_name = buffer.name(); auto it = find(reversed(buffer_name), '/'); if (it != buffer_name.rend()) @@ -311,7 +311,7 @@ void replace_with_char(Context& context, NormalParams) ScopedEdition edition(context); Buffer& buffer = context.buffer(); SelectionList& selections = context.selections(); - std::vector strings; + Vector strings; for (auto& sel : selections) { CharCount count = char_length(buffer, sel); @@ -334,7 +334,7 @@ template void for_each_char(Context& context, NormalParams) { ScopedEdition edition(context); - std::vector sels = context.selections_content(); + Vector sels = context.selections_content(); for (auto& sel : sels) { for (auto& c : sel) @@ -394,7 +394,7 @@ void pipe(Context& context, NormalParams) SelectionList& selections = context.selections(); if (replace) { - std::vector strings; + Vector strings; for (auto& sel : selections) { auto str = content(buffer, sel); @@ -529,7 +529,7 @@ void paste_all(Context& context, NormalParams params) auto strings = RegisterManager::instance()[params.reg].values(context); InsertMode effective_mode = mode; String all; - std::vector offsets; + Vector offsets; for (auto& str : strings) { if (not str.empty() and str.back() == '\n') @@ -545,7 +545,7 @@ void paste_all(Context& context, NormalParams params) } const Buffer& buffer = context.buffer(); - std::vector result; + Vector result; for (auto& selection : selections) { ByteCount pos = 0; @@ -655,7 +655,7 @@ void search_next(Context& context, NormalParams params) template void use_selection_as_search_pattern(Context& context, NormalParams) { - std::vector patterns; + Vector patterns; auto& sels = context.selections(); const auto& buffer = context.buffer(); for (auto& sel : sels) @@ -703,7 +703,7 @@ void split_lines(Context& context, NormalParams) { auto& selections = context.selections(); auto& buffer = context.buffer(); - std::vector res; + Vector res; for (auto& sel : selections) { if (sel.anchor().line == sel.cursor().line) @@ -724,7 +724,7 @@ void split_lines(Context& context, NormalParams) void join_lines_select_spaces(Context& context, NormalParams) { auto& buffer = context.buffer(); - std::vector selections; + Vector selections; for (auto& sel : context.selections()) { const LineCount min_line = sel.min().line; @@ -765,7 +765,7 @@ void keep(Context& context, NormalParams) if (ex.empty()) return; const Buffer& buffer = context.buffer(); - std::vector keep; + Vector keep; for (auto& sel : context.selections()) { if (regex_search(buffer.iterator_at(sel.min()), @@ -787,7 +787,7 @@ void keep_pipe(Context& context, NormalParams) return; const Buffer& buffer = context.buffer(); auto& shell_manager = ShellManager::instance(); - std::vector keep; + Vector keep; for (auto& sel : context.selections()) { int status = 0; @@ -808,7 +808,7 @@ void indent(Context& context, NormalParams) String indent = indent_width == 0 ? "\t" : String{' ', indent_width}; auto& buffer = context.buffer(); - std::vector sels; + Vector sels; LineCount last_line = 0; for (auto& sel : context.selections()) { @@ -837,7 +837,7 @@ void deindent(Context& context, NormalParams) indent_width = tabstop; auto& buffer = context.buffer(); - std::vector sels; + Vector sels; LineCount last_line = 0; for (auto& sel : context.selections()) { @@ -1089,7 +1089,7 @@ void align(Context& context, NormalParams) auto& buffer = context.buffer(); const CharCount tabstop = context.options()["tabstop"].get(); - std::vector> columns; + Vector> columns; LineCount last_line = -1; size_t column = 0; for (auto& sel : selections) @@ -1138,7 +1138,7 @@ void copy_indent(Context& context, NormalParams params) int selection = params.count; auto& buffer = context.buffer(); auto& selections = context.selections(); - std::vector lines; + Vector lines; for (auto sel : selections) { for (LineCount l = sel.min().line; l < sel.max().line + 1; ++l) @@ -1176,8 +1176,8 @@ void tabs_to_spaces(Context& context, NormalParams params) auto& buffer = context.buffer(); const CharCount opt_tabstop = context.options()["tabstop"].get(); const CharCount tabstop = params.count == 0 ? opt_tabstop : params.count; - std::vector tabs; - std::vector spaces; + Vector tabs; + Vector spaces; for (auto& sel : context.selections()) { for (auto it = buffer.iterator_at(sel.min()), @@ -1201,7 +1201,7 @@ void spaces_to_tabs(Context& context, NormalParams params) auto& buffer = context.buffer(); const CharCount opt_tabstop = context.options()["tabstop"].get(); const CharCount tabstop = params.count == 0 ? opt_tabstop : params.count; - std::vector spaces; + Vector spaces; for (auto& sel : context.selections()) { for (auto it = buffer.iterator_at(sel.min()), diff --git a/src/option_types.hh b/src/option_types.hh index eb63ddc8..eda362f3 100644 --- a/src/option_types.hh +++ b/src/option_types.hh @@ -34,8 +34,8 @@ inline void option_from_string(StringView str, bool& opt) constexpr Codepoint list_separator = ':'; -template -String option_to_string(const std::vector& opt) +template +String option_to_string(const Vector& opt) { String res; for (size_t i = 0; i < opt.size(); ++i) @@ -47,8 +47,8 @@ String option_to_string(const std::vector& opt) return res; } -template -void option_from_string(StringView str, std::vector& opt) +template +void option_from_string(StringView str, Vector& opt) { opt.clear(); Vector elems = split(str, list_separator, '\\'); @@ -60,8 +60,8 @@ void option_from_string(StringView str, std::vector& opt) } } -template -bool option_add(std::vector& opt, const std::vector& vec) +template +bool option_add(Vector& opt, const Vector& vec) { std::copy(vec.begin(), vec.end(), back_inserter(opt)); return not vec.empty(); diff --git a/src/register_manager.cc b/src/register_manager.cc index abbd63f9..c98c3964 100644 --- a/src/register_manager.cc +++ b/src/register_manager.cc @@ -14,7 +14,7 @@ class StaticRegister : public Register public: Register& operator=(ArrayView values) override { - m_content = std::vector(values.begin(), values.end()); + m_content = Vector(values.begin(), values.end()); return *this; } @@ -26,7 +26,7 @@ public: return ArrayView(m_content); } protected: - std::vector m_content; + Vector m_content; static const String ms_empty; }; diff --git a/src/register_manager.hh b/src/register_manager.hh index e4391c05..f8b891ee 100644 --- a/src/register_manager.hh +++ b/src/register_manager.hh @@ -4,14 +4,14 @@ #include "register.hh" #include "utils.hh" #include "unordered_map.hh" +#include "vector.hh" -#include #include namespace Kakoune { -using RegisterRetriever = std::function (const Context&)>; +using RegisterRetriever = std::function (const Context&)>; class RegisterManager : public Singleton { diff --git a/src/remote.cc b/src/remote.cc index 0cd2a23c..b7d4cccf 100644 --- a/src/remote.cc +++ b/src/remote.cc @@ -76,7 +76,7 @@ public: } template - void write(const std::vector& vec) + void write(const Vector& vec) { write(ArrayView(vec)); } @@ -127,7 +127,7 @@ public: } private: - std::vector m_stream; + Vector m_stream; int m_socket; }; @@ -174,10 +174,10 @@ String read(int socket) } template -std::vector read_vector(int socket) +Vector read_vector(int socket) { uint32_t size = read(socket); - std::vector res; + Vector res; res.reserve(size); while (size--) res.push_back(read(socket)); diff --git a/src/remote.hh b/src/remote.hh index 89ff6414..2759477a 100644 --- a/src/remote.hh +++ b/src/remote.hh @@ -57,7 +57,7 @@ private: String m_session; std::unique_ptr m_listener; - std::vector> m_accepters; + Vector> m_accepters; }; } diff --git a/src/safe_ptr.hh b/src/safe_ptr.hh index ea662ebc..2f9e4ca5 100644 --- a/src/safe_ptr.hh +++ b/src/safe_ptr.hh @@ -6,8 +6,7 @@ #include "assert.hh" #ifdef SAFE_PTR_TRACK_CALLSTACKS - -#include +#include "vector.hh" #include #endif @@ -155,7 +154,7 @@ private: Backtrace bt; }; - mutable std::vector m_callstacks; + mutable Vector m_callstacks; #endif mutable int m_count; #endif diff --git a/src/selection.cc b/src/selection.cc index cc98c918..8ad933a4 100644 --- a/src/selection.cc +++ b/src/selection.cc @@ -25,14 +25,14 @@ SelectionList::SelectionList(Buffer& buffer, Selection s) : SelectionList(buffer, std::move(s), buffer.timestamp()) {} -SelectionList::SelectionList(Buffer& buffer, std::vector s, size_t timestamp) +SelectionList::SelectionList(Buffer& buffer, Vector s, size_t timestamp) : m_buffer(&buffer), m_selections(std::move(s)), m_timestamp(timestamp) { kak_assert(size() > 0); check_invariant(); } -SelectionList::SelectionList(Buffer& buffer, std::vector s) +SelectionList::SelectionList(Buffer& buffer, Vector s) : SelectionList(buffer, std::move(s), buffer.timestamp()) {} @@ -196,7 +196,7 @@ const Buffer::Change* backward_sorted_until(const Buffer::Change* first, const B return last; } -void update_forward(ArrayView changes, std::vector& selections, size_t& main) +void update_forward(ArrayView changes, Vector& selections, size_t& main) { ForwardChangesTracker changes_tracker; @@ -221,7 +221,7 @@ void update_forward(ArrayView changes, std::vector& s kak_assert(std::is_sorted(selections.begin(), selections.end(), compare_selections)); } -void update_backward(ArrayView changes, std::vector& selections, size_t& main) +void update_backward(ArrayView changes, Vector& selections, size_t& main) { ForwardChangesTracker changes_tracker; @@ -258,9 +258,9 @@ void update_backward(ArrayView changes, std::vector& } -std::vector compute_modified_ranges(Buffer& buffer, size_t timestamp) +Vector compute_modified_ranges(Buffer& buffer, size_t timestamp) { - std::vector ranges; + Vector ranges; auto changes = buffer.changes_since(timestamp); auto change_it = changes.begin(); while (change_it != changes.end()) diff --git a/src/selection.hh b/src/selection.hh index c426702f..8370df1f 100644 --- a/src/selection.hh +++ b/src/selection.hh @@ -6,7 +6,7 @@ namespace Kakoune { -using CaptureList = std::vector; +using CaptureList = Vector; // A selection is a Selection, associated with a CaptureList struct Selection @@ -70,8 +70,8 @@ struct SelectionList { SelectionList(Buffer& buffer, Selection s); SelectionList(Buffer& buffer, Selection s, size_t timestamp); - SelectionList(Buffer& buffer, std::vector s); - SelectionList(Buffer& buffer, std::vector s, size_t timestamp); + SelectionList(Buffer& buffer, Vector s); + SelectionList(Buffer& buffer, Vector s, size_t timestamp); void update(); @@ -92,7 +92,7 @@ struct SelectionList Selection& operator[](size_t i) { return m_selections[i]; } const Selection& operator[](size_t i) const { return m_selections[i]; } - SelectionList& operator=(std::vector list) + SelectionList& operator=(Vector list) { m_selections = std::move(list); m_main = size()-1; @@ -102,11 +102,11 @@ struct SelectionList return *this; } - using iterator = std::vector::iterator; + using iterator = Vector::iterator; iterator begin() { return m_selections.begin(); } iterator end() { return m_selections.end(); } - using const_iterator = std::vector::const_iterator; + using const_iterator = Vector::const_iterator; const_iterator begin() const { return m_selections.begin(); } const_iterator end() const { return m_selections.end(); } @@ -130,13 +130,13 @@ struct SelectionList private: size_t m_main = 0; - std::vector m_selections; + Vector m_selections; safe_ptr m_buffer; size_t m_timestamp; }; -std::vector compute_modified_ranges(Buffer& buffer, size_t timestamp); +Vector compute_modified_ranges(Buffer& buffer, size_t timestamp); } diff --git a/src/selectors.cc b/src/selectors.cc index 0f4c5106..f5fdb088 100644 --- a/src/selectors.cc +++ b/src/selectors.cc @@ -31,9 +31,9 @@ Selection select_line(const Buffer& buffer, const Selection& selection) Selection select_matching(const Buffer& buffer, const Selection& selection) { - std::vector matching_pairs = { '(', ')', '{', '}', '[', ']', '<', '>' }; + Vector matching_pairs = { '(', ')', '{', '}', '[', ']', '<', '>' }; Utf8Iterator it = buffer.iterator_at(selection.cursor()); - std::vector::iterator match = matching_pairs.end(); + Vector::iterator match = matching_pairs.end(); while (not is_eol(*it)) { match = std::find(matching_pairs.begin(), matching_pairs.end(), *it); @@ -500,7 +500,7 @@ using RegexIt = RegexIterator; void select_all_matches(SelectionList& selections, const Regex& regex) { - std::vector result; + Vector result; auto& buffer = selections.buffer(); for (auto& sel : selections) { @@ -533,7 +533,7 @@ void select_all_matches(SelectionList& selections, const Regex& regex) void split_selections(SelectionList& selections, const Regex& regex) { - std::vector result; + Vector result; auto& buffer = selections.buffer(); auto buf_end = buffer.end(); for (auto& sel : selections) diff --git a/src/shell_manager.cc b/src/shell_manager.cc index 2a995b13..697dfa0e 100644 --- a/src/shell_manager.cc +++ b/src/shell_manager.cc @@ -128,7 +128,7 @@ String ShellManager::pipe(StringView input, } const char* shell = "/bin/sh"; auto cmdlinezstr = cmdline.zstr(); - std::vector execparams = { shell, "-c", cmdlinezstr }; + Vector execparams = { shell, "-c", cmdlinezstr }; if (not params.empty()) execparams.push_back(shell); for (auto& param : params) diff --git a/src/shell_manager.hh b/src/shell_manager.hh index cf079b24..6206b90c 100644 --- a/src/shell_manager.hh +++ b/src/shell_manager.hh @@ -35,7 +35,7 @@ public: String get_val(StringView name, const Context& context) const; private: - std::vector> m_env_vars; + Vector> m_env_vars; }; } diff --git a/src/unit_tests.cc b/src/unit_tests.cc index 007922b4..4b8dcbda 100644 --- a/src/unit_tests.cc +++ b/src/unit_tests.cc @@ -53,7 +53,7 @@ void test_buffer() void test_undo_group_optimizer() { - std::vector lines = { "allo ?\n", "mais que fais la police\n", " hein ?\n", " youpi\n" }; + Vector lines = { "allo ?\n", "mais que fais la police\n", " hein ?\n", " youpi\n" }; Buffer buffer("test", Buffer::Flags::None, lines); auto pos = buffer.insert(buffer.end(), "kanaky\n"); buffer.erase(pos, buffer.end()); diff --git a/src/word_db.hh b/src/word_db.hh index e50e0edc..313579cd 100644 --- a/src/word_db.hh +++ b/src/word_db.hh @@ -39,6 +39,8 @@ public: } int get_word_occurences(StringView word) const; +private: + using LineToWords = Vector; struct WordInfo { @@ -46,8 +48,6 @@ public: int refcount; }; using WordToInfo = UnorderedMap; -private: - using LineToWords = Vector; void update_db(); void add_words(const WordList& words);