replace all std::vector with Vector

This commit is contained in:
Maxime Coste 2015-01-12 13:58:41 +00:00
parent 83d0813b0f
commit da562e03a0
36 changed files with 126 additions and 130 deletions

View File

@ -30,9 +30,9 @@ StringView AliasRegistry::operator[](const String& alias) const
return StringView{}; return StringView{};
} }
std::vector<StringView> AliasRegistry::aliases_for(StringView command) const Vector<StringView> AliasRegistry::aliases_for(StringView command) const
{ {
std::vector<StringView> res; Vector<StringView> res;
if (m_parent) if (m_parent)
res = m_parent->aliases_for(command); res = m_parent->aliases_for(command);

View File

@ -16,7 +16,7 @@ public:
void remove_alias(const String& alias); void remove_alias(const String& alias);
StringView operator[](const String& name) const; StringView operator[](const String& name) const;
std::vector<StringView> aliases_for(StringView command) const; Vector<StringView> aliases_for(StringView command) const;
private: private:
friend class Scope; friend class Scope;

View File

@ -15,7 +15,7 @@
namespace Kakoune namespace Kakoune
{ {
Buffer::Buffer(String name, Flags flags, std::vector<String> lines, Buffer::Buffer(String name, Flags flags, Vector<String> lines,
time_t fs_timestamp) time_t fs_timestamp)
: Scope(GlobalScope::instance()), : Scope(GlobalScope::instance()),
m_name(flags & Flags::File ? real_path(parse_filename(name)) : std::move(name)), 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<String> lines, time_t fs_timestamp) void Buffer::reload(Vector<String> lines, time_t fs_timestamp)
{ {
m_changes.push_back({ Change::Erase, {0,0}, back_coord(), true }); 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 prefix = m_lines[pos.line].substr(0, pos.column);
StringView suffix = m_lines[pos.line].substr(pos.column); StringView suffix = m_lines[pos.line].substr(pos.column);
std::vector<InternedString> new_lines; Vector<InternedString> new_lines;
ByteCount start = 0; ByteCount start = 0;
for (ByteCount i = 0; i < content.length(); ++i) for (ByteCount i = 0; i < content.length(); ++i)

View File

@ -7,8 +7,7 @@
#include "scope.hh" #include "scope.hh"
#include "interned_string.hh" #include "interned_string.hh"
#include "value.hh" #include "value.hh"
#include "vector.hh"
#include <vector>
namespace Kakoune namespace Kakoune
{ {
@ -77,7 +76,7 @@ public:
NoUndo = 8, NoUndo = 8,
}; };
Buffer(String name, Flags flags, std::vector<String> lines = { "\n" }, Buffer(String name, Flags flags, Vector<String> lines = { "\n" },
time_t fs_timestamp = InvalidTime); time_t fs_timestamp = InvalidTime);
Buffer(const Buffer&) = delete; Buffer(const Buffer&) = delete;
Buffer& operator= (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 run_hook_in_own_context(const String& hook_name, StringView param);
void reload(std::vector<String> lines, time_t fs_timestamp = InvalidTime); void reload(Vector<String> lines, time_t fs_timestamp = InvalidTime);
void check_invariant() const; void check_invariant() const;
@ -187,7 +186,7 @@ private:
Flags m_flags; Flags m_flags;
struct Modification; struct Modification;
using UndoGroup = std::vector<Modification>; using UndoGroup = Vector<Modification>;
friend class UndoGroupOptimizer; friend class UndoGroupOptimizer;
using History = Vector<UndoGroup, MemoryDomain::BufferMeta>; using History = Vector<UndoGroup, MemoryDomain::BufferMeta>;

View File

@ -13,7 +13,7 @@ class Buffer;
class BufferManager : public Singleton<BufferManager> class BufferManager : public Singleton<BufferManager>
{ {
public: public:
using BufferList = std::vector<safe_ptr<Buffer>>; using BufferList = Vector<safe_ptr<Buffer>>;
using iterator = BufferList::const_iterator; using iterator = BufferList::const_iterator;
~BufferManager(); ~BufferManager();

View File

@ -39,7 +39,7 @@ Buffer* create_buffer_from_data(StringView data, StringView name,
pos = data.begin() + 3; pos = data.begin() + 3;
} }
std::vector<String> lines; Vector<String> lines;
while (pos < data.end()) while (pos < data.end())
{ {
const char* line_end = pos; const char* line_end = pos;
@ -88,7 +88,7 @@ Buffer* create_fifo_buffer(String name, int fd, bool scroll)
if (buffer) if (buffer)
{ {
buffer->flags() |= Buffer::Flags::NoUndo; buffer->flags() |= Buffer::Flags::NoUndo;
buffer->reload(std::vector<String>({"\n"_str}), 0); buffer->reload(Vector<String>({"\n"_str}), 0);
} }
else else
buffer = new Buffer(std::move(name), Buffer::Flags::Fifo | Buffer::Flags::NoUndo); buffer = new Buffer(std::move(name), Buffer::Flags::Fifo | Buffer::Flags::NoUndo);

View File

@ -48,8 +48,8 @@ public:
private: private:
String generate_name() const; String generate_name() const;
std::vector<std::unique_ptr<Client>> m_clients; Vector<std::unique_ptr<Client>> m_clients;
std::vector<WindowAndSelections> m_free_windows; Vector<WindowAndSelections> m_free_windows;
}; };
} }

View File

@ -70,7 +70,7 @@ private:
}; };
using TokenList = std::vector<Token>; using TokenList = Vector<Token>;
bool is_command_separator(char c) bool is_command_separator(char c)
{ {
@ -402,7 +402,7 @@ void CommandManager::execute(StringView command_line,
return; return;
CharCoord command_coord; CharCoord command_coord;
std::vector<String> params; Vector<String> params;
for (auto it = tokens.begin(); it != tokens.end(); ++it) for (auto it = tokens.begin(); it != tokens.end(); ++it)
{ {
if (params.empty()) if (params.empty())
@ -556,7 +556,7 @@ Completions CommandManager::complete(const Context& context,
not command_it->second.completer) not command_it->second.completer)
return Completions(); return Completions();
std::vector<String> params; Vector<String> params;
for (auto token_it = tokens.begin() + cmd_idx + 1; for (auto token_it = tokens.begin() + cmd_idx + 1;
token_it != tokens.end(); ++token_it) token_it != tokens.end(); ++token_it)
params.push_back(token_it->content()); params.push_back(token_it->content());

View File

@ -260,7 +260,7 @@ void quit()
{ {
if (not force and ClientManager::instance().count() == 1) if (not force and ClientManager::instance().count() == 1)
{ {
std::vector<String> names; Vector<String> names;
for (auto& buffer : BufferManager::instance()) for (auto& buffer : BufferManager::instance())
{ {
if ((buffer->flags() & Buffer::Flags::File) and buffer->is_modified()) if ((buffer->flags() & Buffer::Flags::File) and buffer->is_modified())
@ -495,7 +495,7 @@ const CommandDesc add_highlighter_cmd = {
auto begin = parser.begin(); auto begin = parser.begin();
const String& name = *begin++; const String& name = *begin++;
std::vector<String> highlighter_params; Vector<String> highlighter_params;
for (; begin != parser.end(); ++begin) for (; begin != parser.end(); ++begin)
highlighter_params.push_back(*begin); highlighter_params.push_back(*begin);
@ -609,9 +609,9 @@ const CommandDesc rm_hook_cmd = {
} }
}; };
std::vector<String> params_to_shell(const ParametersParser& parser) Vector<String> params_to_shell(const ParametersParser& parser)
{ {
std::vector<String> vars; Vector<String> vars;
for (size_t i = 0; i < parser.positional_count(); ++i) for (size_t i = 0; i < parser.positional_count(); ++i)
vars.push_back(parser[i]); vars.push_back(parser[i]);
return vars; return vars;
@ -1255,9 +1255,9 @@ const CommandDesc menu_cmd = {
return; return;
} }
std::vector<String> choices; Vector<String> choices;
std::vector<String> commands; Vector<String> commands;
std::vector<String> select_cmds; Vector<String> select_cmds;
for (int i = 0; i < count; i += modulo) for (int i = 0; i < count; i += modulo)
{ {
choices.push_back(parser[i]); choices.push_back(parser[i]);
@ -1424,14 +1424,14 @@ public:
: m_name(name) : m_name(name)
{ {
ArrayView<String> save = RegisterManager::instance()[name].values(context); ArrayView<String> save = RegisterManager::instance()[name].values(context);
m_save = std::vector<String>(save.begin(), save.end()); m_save = Vector<String>(save.begin(), save.end());
} }
~RegisterRestorer() ~RegisterRestorer()
{ RegisterManager::instance()[m_name] = m_save; } { RegisterManager::instance()[m_name] = m_save; }
private: private:
std::vector<String> m_save; Vector<String> m_save;
char m_name; char m_name;
}; };

View File

@ -202,16 +202,16 @@ const SelectionList& Context::selections() const
return const_cast<Context&>(*this).selections(); return const_cast<Context&>(*this).selections();
} }
std::vector<String> Context::selections_content() const Vector<String> Context::selections_content() const
{ {
auto& buf = buffer(); auto& buf = buffer();
std::vector<String> contents; Vector<String> contents;
for (auto& sel : selections()) for (auto& sel : selections())
contents.push_back(buf.string(sel.min(), buf.char_next(sel.max()))); contents.push_back(buf.string(sel.min(), buf.char_next(sel.max())));
return contents; return contents;
} }
void Context::set_selections(std::vector<Selection> sels) void Context::set_selections(Vector<Selection> sels)
{ {
*m_selections = std::move(sels); *m_selections = std::move(sels);
(*m_selections).check_invariant(); (*m_selections).check_invariant();

View File

@ -88,8 +88,8 @@ public:
SelectionList& selections(); SelectionList& selections();
const SelectionList& selections() const; const SelectionList& selections() const;
std::vector<String> selections_content() const; Vector<String> selections_content() const;
void set_selections(std::vector<Selection> sels); void set_selections(Vector<Selection> sels);
void change_buffer(Buffer& buffer); void change_buffer(Buffer& buffer);
@ -147,7 +147,7 @@ private:
String m_name; String m_name;
using JumpList = std::vector<SelectionList>; using JumpList = Vector<SelectionList>;
JumpList m_jump_list; JumpList m_jump_list;
JumpList::iterator m_current_jump = m_jump_list.begin(); JumpList::iterator m_current_jump = m_jump_list.begin();

View File

@ -4,8 +4,7 @@
#include "face.hh" #include "face.hh"
#include "coord.hh" #include "coord.hh"
#include "string.hh" #include "string.hh"
#include "vector.hh"
#include <vector>
namespace Kakoune namespace Kakoune
{ {
@ -81,7 +80,7 @@ private:
}; };
using BufferRange = std::pair<ByteCoord, ByteCoord>; using BufferRange = std::pair<ByteCoord, ByteCoord>;
using AtomList = std::vector<DisplayAtom>; using AtomList = Vector<DisplayAtom>;
class DisplayLine class DisplayLine
{ {
@ -127,7 +126,7 @@ private:
class DisplayBuffer class DisplayBuffer
{ {
public: public:
using LineList = std::vector<DisplayLine>; using LineList = Vector<DisplayLine>;
DisplayBuffer() {} DisplayBuffer() {}
LineList& lines() { return m_lines; } LineList& lines() { return m_lines; }

View File

@ -3,9 +3,9 @@
#include "utils.hh" #include "utils.hh"
#include "flags.hh" #include "flags.hh"
#include "vector.hh"
#include <chrono> #include <chrono>
#include <vector>
#include <functional> #include <functional>
#include <sys/select.h> #include <sys/select.h>
@ -84,8 +84,8 @@ public:
private: private:
friend class FDWatcher; friend class FDWatcher;
friend class Timer; friend class Timer;
std::vector<FDWatcher*> m_fd_watchers; Vector<FDWatcher*> m_fd_watchers;
std::vector<Timer*> m_timers; Vector<Timer*> m_timers;
fd_set m_forced_fd; fd_set m_forced_fd;
TimePoint m_last; TimePoint m_last;

View File

@ -207,7 +207,7 @@ public:
if (flags != HighlightFlags::Highlight) if (flags != HighlightFlags::Highlight)
return; return;
std::vector<Optional<Face>> faces(m_faces.size()); Vector<Optional<Face>> faces(m_faces.size());
auto& cache = update_cache_ifn(context.buffer(), display_buffer.range()); auto& cache = update_cache_ifn(context.buffer(), display_buffer.range());
for (auto& match : cache.m_matches) for (auto& match : cache.m_matches)
{ {
@ -645,13 +645,13 @@ HighlighterAndId create_flag_lines_highlighter(HighlighterParameters params)
Color bg = str_to_color(params[0]); Color bg = str_to_color(params[0]);
// throw if wrong option type // throw if wrong option type
GlobalScope::instance().options()[option_name].get<std::vector<LineAndFlag>>(); GlobalScope::instance().options()[option_name].get<Vector<LineAndFlag>>();
auto func = [=](const Context& context, HighlightFlags flags, auto func = [=](const Context& context, HighlightFlags flags,
DisplayBuffer& display_buffer, BufferRange) DisplayBuffer& display_buffer, BufferRange)
{ {
auto& lines_opt = context.options()[option_name]; auto& lines_opt = context.options()[option_name];
auto& lines = lines_opt.get<std::vector<LineAndFlag>>(); auto& lines = lines_opt.get<Vector<LineAndFlag>>();
CharCount width = 0; CharCount width = 0;
for (auto& l : lines) for (auto& l : lines)

View File

@ -440,7 +440,7 @@ public:
private: private:
MenuCallback m_callback; MenuCallback m_callback;
using ChoiceList = std::vector<String>; using ChoiceList = Vector<String>;
const ChoiceList m_choices; const ChoiceList m_choices;
ChoiceList::const_iterator m_selected; ChoiceList::const_iterator m_selected;
@ -476,13 +476,13 @@ String common_prefix(ArrayView<String> strings)
return res; return res;
} }
void history_push(std::vector<String>& history, StringView entry) void history_push(Vector<String>& history, StringView entry)
{ {
if(entry.empty()) if(entry.empty())
{ {
return; return;
} }
std::vector<String>::iterator it; Vector<String>::iterator it;
while ((it = find(history, entry)) != history.end()) while ((it = find(history, entry)) != history.end())
history.erase(it); history.erase(it);
history.push_back(entry); history.push_back(entry);
@ -507,7 +507,7 @@ public:
void on_key(Key key) override void on_key(Key key) override
{ {
std::vector<String>& history = ms_history[m_prompt]; Vector<String>& history = ms_history[m_prompt];
const String& line = m_line_editor.line(); const String& line = m_line_editor.line();
bool showcompl = false; bool showcompl = false;
@ -739,10 +739,10 @@ private:
bool m_autoshowcompl; bool m_autoshowcompl;
Mode m_mode = Mode::Default; Mode m_mode = Mode::Default;
static UnorderedMap<String, std::vector<String>> ms_history; static UnorderedMap<String, Vector<String>> ms_history;
std::vector<String>::iterator m_history_it; Vector<String>::iterator m_history_it;
}; };
UnorderedMap<String, std::vector<String>> Prompt::ms_history; UnorderedMap<String, Vector<String>> Prompt::ms_history;
class NextKey : public InputMode class NextKey : public InputMode
{ {
@ -828,7 +828,7 @@ public:
} }
else if (key == Key::Backspace) else if (key == Key::Backspace)
{ {
std::vector<Selection> sels; Vector<Selection> sels;
for (auto& sel : context().selections()) for (auto& sel : context().selections())
{ {
if (sel.cursor() == ByteCoord{0,0}) if (sel.cursor() == ByteCoord{0,0})
@ -841,7 +841,7 @@ public:
} }
else if (key == Key::Delete) else if (key == Key::Delete)
{ {
std::vector<Selection> sels; Vector<Selection> sels;
for (auto& sel : context().selections()) for (auto& sel : context().selections())
sels.push_back({ sel.cursor() }); sels.push_back({ sel.cursor() });
SelectionList{buffer, std::move(sels)}.erase(); SelectionList{buffer, std::move(sels)}.erase();
@ -1067,7 +1067,7 @@ void InputHandler::repeat_last_insert()
if (m_last_insert.second.empty()) if (m_last_insert.second.empty())
return; return;
std::vector<Key> keys; Vector<Key> keys;
swap(keys, m_last_insert.second); swap(keys, m_last_insert.second);
// context.last_insert will be refilled by the new Insert // context.last_insert will be refilled by the new Insert
// this is very inefficient. // this is very inefficient.

View File

@ -88,11 +88,11 @@ private:
friend class InputMode; friend class InputMode;
std::unique_ptr<InputMode> m_mode; std::unique_ptr<InputMode> m_mode;
std::vector<std::unique_ptr<InputMode>> m_mode_trash; Vector<std::unique_ptr<InputMode>> m_mode_trash;
void change_input_mode(InputMode* new_mode); void change_input_mode(InputMode* new_mode);
using Insertion = std::pair<InsertMode, std::vector<Key>>; using Insertion = std::pair<InsertMode, Vector<Key>>;
Insertion m_last_insert = {InsertMode::Insert, {}}; Insertion m_last_insert = {InsertMode::Insert, {}};
char m_recording_reg = 0; char m_recording_reg = 0;

View File

@ -385,7 +385,7 @@ void InsertCompleter::menu_show()
const CharCount tabstop = m_options["tabstop"].get<int>(); const CharCount tabstop = m_options["tabstop"].get<int>();
const CharCount column = get_column(m_context.buffer(), tabstop, const CharCount column = get_column(m_context.buffer(), tabstop,
m_completions.begin); m_completions.begin);
std::vector<String> menu_entries; Vector<String> menu_entries;
for (auto& candidate : m_matching_candidates) for (auto& candidate : m_matching_candidates)
menu_entries.push_back(expand_tabs(candidate.first, tabstop, column)); 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) void InsertCompleter::on_option_changed(const Option& opt)
{ {
auto& completers = m_options["completers"].get<InsertCompleterDescList>(); auto& completers = m_options["completers"].get<InsertCompleterDescList>();
std::vector<StringView> option_names; Vector<StringView> option_names;
for (auto& completer : completers) for (auto& completer : completers)
{ {
if (completer.mode == InsertCompleterDesc::Option) if (completer.mode == InsertCompleterDesc::Option)

View File

@ -42,9 +42,9 @@ struct LineChange
} }
std::vector<LineModification> compute_line_modifications(const Buffer& buffer, size_t timestamp) Vector<LineModification> compute_line_modifications(const Buffer& buffer, size_t timestamp)
{ {
std::vector<LineModification> res; Vector<LineModification> res;
for (auto& buf_change : buffer.changes_since(timestamp)) for (auto& buf_change : buffer.changes_since(timestamp))
{ {
const LineChange change(buf_change); const LineChange change(buf_change);

View File

@ -3,8 +3,7 @@
#include "units.hh" #include "units.hh"
#include "utils.hh" #include "utils.hh"
#include "vector.hh"
#include <vector>
namespace Kakoune namespace Kakoune
{ {
@ -21,7 +20,7 @@ struct LineModification
LineCount diff() const { return new_line - old_line + num_added - num_removed; } LineCount diff() const { return new_line - old_line + num_added - num_removed; }
}; };
std::vector<LineModification> compute_line_modifications(const Buffer& buffer, size_t timestamp); Vector<LineModification> compute_line_modifications(const Buffer& buffer, size_t timestamp);
} }

View File

@ -144,7 +144,7 @@ void register_env_vars()
void register_registers() void register_registers()
{ {
using StringList = std::vector<String>; using StringList = Vector<String>;
static const struct { static const struct {
char name; char name;
StringList (*func)(const Context&); StringList (*func)(const Context&);
@ -167,7 +167,7 @@ void register_registers()
{ {
register_manager.register_dynamic_register('0'+i, register_manager.register_dynamic_register('0'+i,
[i](const Context& context) { [i](const Context& context) {
std::vector<String> result; Vector<String> result;
for (auto& sel : context.selections()) for (auto& sel : context.selections())
result.emplace_back(i < sel.captures().size() ? sel.captures()[i] : ""); result.emplace_back(i < sel.captures().size() ? sel.captures()[i] : "");
return result; return result;
@ -210,7 +210,7 @@ void register_options()
Regex{}); Regex{});
reg.declare_option("filetype", "buffer filetype", ""_str); reg.declare_option("filetype", "buffer filetype", ""_str);
reg.declare_option("path", "path to consider when trying to find a file", reg.declare_option("path", "path to consider when trying to find a file",
std::vector<String>({ "./", "/usr/include" })); Vector<String>({ "./", "/usr/include" }));
reg.declare_option("completers", "insert mode completers to execute.", reg.declare_option("completers", "insert mode completers to execute.",
InsertCompleterDescList({ InsertCompleterDescList({
InsertCompleterDesc{ InsertCompleterDesc::Filename }, InsertCompleterDesc{ InsertCompleterDesc::Filename },
@ -508,7 +508,7 @@ int main(int argc, char* argv[])
signal(SIGQUIT, signal_handler); signal(SIGQUIT, signal_handler);
signal(SIGTERM, signal_handler); signal(SIGTERM, signal_handler);
std::vector<String> params; Vector<String> params;
for (size_t i = 1; i < argc; ++i) for (size_t i = 1; i < argc; ++i)
params.push_back(argv[i]); params.push_back(argv[i]);
@ -540,7 +540,7 @@ int main(int argc, char* argv[])
} }
else if (parser.has_option("f")) else if (parser.has_option("f"))
{ {
std::vector<StringView> files; Vector<StringView> files;
for (size_t i = 0; i < parser.positional_count(); ++i) for (size_t i = 0; i < parser.positional_count(); ++i)
files.emplace_back(parser[i]); files.emplace_back(parser[i]);
@ -566,7 +566,7 @@ int main(int argc, char* argv[])
} }
else else
{ {
std::vector<StringView> files; Vector<StringView> files;
for (size_t i = 0; i < parser.positional_count(); ++i) for (size_t i = 0; i < parser.positional_count(); ++i)
files.emplace_back(parser[i]); files.emplace_back(parser[i]);
StringView session; StringView session;

View File

@ -693,7 +693,7 @@ template<bool assist = true>
static String make_info_box(StringView title, StringView message, static String make_info_box(StringView title, StringView message,
CharCount max_width) CharCount max_width)
{ {
static const std::vector<String> assistant = static const Vector<String> assistant =
{ " ╭──╮ ", { " ╭──╮ ",
" │ │ ", " │ │ ",
" @ @ ╭", " @ @ ╭",

View File

@ -58,7 +58,7 @@ private:
void update_dimensions(); void update_dimensions();
NCursesWin* m_menu_win = nullptr; NCursesWin* m_menu_win = nullptr;
std::vector<String> m_items; Vector<String> m_items;
Face m_menu_fg; Face m_menu_fg;
Face m_menu_bg; Face m_menu_bg;
int m_selected_item = 0; int m_selected_item = 0;

View File

@ -211,7 +211,7 @@ void goto_commands(Context& context, NormalParams params)
if (contains(filename, c)) if (contains(filename, c))
return; return;
auto paths = context.options()["path"].get<std::vector<String>>(); auto paths = context.options()["path"].get<Vector<String>>();
const String& buffer_name = buffer.name(); const String& buffer_name = buffer.name();
auto it = find(reversed(buffer_name), '/'); auto it = find(reversed(buffer_name), '/');
if (it != buffer_name.rend()) if (it != buffer_name.rend())
@ -311,7 +311,7 @@ void replace_with_char(Context& context, NormalParams)
ScopedEdition edition(context); ScopedEdition edition(context);
Buffer& buffer = context.buffer(); Buffer& buffer = context.buffer();
SelectionList& selections = context.selections(); SelectionList& selections = context.selections();
std::vector<String> strings; Vector<String> strings;
for (auto& sel : selections) for (auto& sel : selections)
{ {
CharCount count = char_length(buffer, sel); CharCount count = char_length(buffer, sel);
@ -334,7 +334,7 @@ template<Codepoint (*func)(Codepoint)>
void for_each_char(Context& context, NormalParams) void for_each_char(Context& context, NormalParams)
{ {
ScopedEdition edition(context); ScopedEdition edition(context);
std::vector<String> sels = context.selections_content(); Vector<String> sels = context.selections_content();
for (auto& sel : sels) for (auto& sel : sels)
{ {
for (auto& c : sel) for (auto& c : sel)
@ -394,7 +394,7 @@ void pipe(Context& context, NormalParams)
SelectionList& selections = context.selections(); SelectionList& selections = context.selections();
if (replace) if (replace)
{ {
std::vector<String> strings; Vector<String> strings;
for (auto& sel : selections) for (auto& sel : selections)
{ {
auto str = content(buffer, sel); auto str = content(buffer, sel);
@ -529,7 +529,7 @@ void paste_all(Context& context, NormalParams params)
auto strings = RegisterManager::instance()[params.reg].values(context); auto strings = RegisterManager::instance()[params.reg].values(context);
InsertMode effective_mode = mode; InsertMode effective_mode = mode;
String all; String all;
std::vector<ByteCount> offsets; Vector<ByteCount> offsets;
for (auto& str : strings) for (auto& str : strings)
{ {
if (not str.empty() and str.back() == '\n') if (not str.empty() and str.back() == '\n')
@ -545,7 +545,7 @@ void paste_all(Context& context, NormalParams params)
} }
const Buffer& buffer = context.buffer(); const Buffer& buffer = context.buffer();
std::vector<Selection> result; Vector<Selection> result;
for (auto& selection : selections) for (auto& selection : selections)
{ {
ByteCount pos = 0; ByteCount pos = 0;
@ -655,7 +655,7 @@ void search_next(Context& context, NormalParams params)
template<bool smart> template<bool smart>
void use_selection_as_search_pattern(Context& context, NormalParams) void use_selection_as_search_pattern(Context& context, NormalParams)
{ {
std::vector<String> patterns; Vector<String> patterns;
auto& sels = context.selections(); auto& sels = context.selections();
const auto& buffer = context.buffer(); const auto& buffer = context.buffer();
for (auto& sel : sels) for (auto& sel : sels)
@ -703,7 +703,7 @@ void split_lines(Context& context, NormalParams)
{ {
auto& selections = context.selections(); auto& selections = context.selections();
auto& buffer = context.buffer(); auto& buffer = context.buffer();
std::vector<Selection> res; Vector<Selection> res;
for (auto& sel : selections) for (auto& sel : selections)
{ {
if (sel.anchor().line == sel.cursor().line) 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) void join_lines_select_spaces(Context& context, NormalParams)
{ {
auto& buffer = context.buffer(); auto& buffer = context.buffer();
std::vector<Selection> selections; Vector<Selection> selections;
for (auto& sel : context.selections()) for (auto& sel : context.selections())
{ {
const LineCount min_line = sel.min().line; const LineCount min_line = sel.min().line;
@ -765,7 +765,7 @@ void keep(Context& context, NormalParams)
if (ex.empty()) if (ex.empty())
return; return;
const Buffer& buffer = context.buffer(); const Buffer& buffer = context.buffer();
std::vector<Selection> keep; Vector<Selection> keep;
for (auto& sel : context.selections()) for (auto& sel : context.selections())
{ {
if (regex_search(buffer.iterator_at(sel.min()), if (regex_search(buffer.iterator_at(sel.min()),
@ -787,7 +787,7 @@ void keep_pipe(Context& context, NormalParams)
return; return;
const Buffer& buffer = context.buffer(); const Buffer& buffer = context.buffer();
auto& shell_manager = ShellManager::instance(); auto& shell_manager = ShellManager::instance();
std::vector<Selection> keep; Vector<Selection> keep;
for (auto& sel : context.selections()) for (auto& sel : context.selections())
{ {
int status = 0; int status = 0;
@ -808,7 +808,7 @@ void indent(Context& context, NormalParams)
String indent = indent_width == 0 ? "\t" : String{' ', indent_width}; String indent = indent_width == 0 ? "\t" : String{' ', indent_width};
auto& buffer = context.buffer(); auto& buffer = context.buffer();
std::vector<Selection> sels; Vector<Selection> sels;
LineCount last_line = 0; LineCount last_line = 0;
for (auto& sel : context.selections()) for (auto& sel : context.selections())
{ {
@ -837,7 +837,7 @@ void deindent(Context& context, NormalParams)
indent_width = tabstop; indent_width = tabstop;
auto& buffer = context.buffer(); auto& buffer = context.buffer();
std::vector<Selection> sels; Vector<Selection> sels;
LineCount last_line = 0; LineCount last_line = 0;
for (auto& sel : context.selections()) for (auto& sel : context.selections())
{ {
@ -1089,7 +1089,7 @@ void align(Context& context, NormalParams)
auto& buffer = context.buffer(); auto& buffer = context.buffer();
const CharCount tabstop = context.options()["tabstop"].get<int>(); const CharCount tabstop = context.options()["tabstop"].get<int>();
std::vector<std::vector<const Selection*>> columns; Vector<Vector<const Selection*>> columns;
LineCount last_line = -1; LineCount last_line = -1;
size_t column = 0; size_t column = 0;
for (auto& sel : selections) for (auto& sel : selections)
@ -1138,7 +1138,7 @@ void copy_indent(Context& context, NormalParams params)
int selection = params.count; int selection = params.count;
auto& buffer = context.buffer(); auto& buffer = context.buffer();
auto& selections = context.selections(); auto& selections = context.selections();
std::vector<LineCount> lines; Vector<LineCount> lines;
for (auto sel : selections) for (auto sel : selections)
{ {
for (LineCount l = sel.min().line; l < sel.max().line + 1; ++l) 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(); auto& buffer = context.buffer();
const CharCount opt_tabstop = context.options()["tabstop"].get<int>(); const CharCount opt_tabstop = context.options()["tabstop"].get<int>();
const CharCount tabstop = params.count == 0 ? opt_tabstop : params.count; const CharCount tabstop = params.count == 0 ? opt_tabstop : params.count;
std::vector<Selection> tabs; Vector<Selection> tabs;
std::vector<String> spaces; Vector<String> spaces;
for (auto& sel : context.selections()) for (auto& sel : context.selections())
{ {
for (auto it = buffer.iterator_at(sel.min()), for (auto it = buffer.iterator_at(sel.min()),
@ -1201,7 +1201,7 @@ void spaces_to_tabs(Context& context, NormalParams params)
auto& buffer = context.buffer(); auto& buffer = context.buffer();
const CharCount opt_tabstop = context.options()["tabstop"].get<int>(); const CharCount opt_tabstop = context.options()["tabstop"].get<int>();
const CharCount tabstop = params.count == 0 ? opt_tabstop : params.count; const CharCount tabstop = params.count == 0 ? opt_tabstop : params.count;
std::vector<Selection> spaces; Vector<Selection> spaces;
for (auto& sel : context.selections()) for (auto& sel : context.selections())
{ {
for (auto it = buffer.iterator_at(sel.min()), for (auto it = buffer.iterator_at(sel.min()),

View File

@ -34,8 +34,8 @@ inline void option_from_string(StringView str, bool& opt)
constexpr Codepoint list_separator = ':'; constexpr Codepoint list_separator = ':';
template<typename T, typename Alloc> template<typename T, MemoryDomain domain>
String option_to_string(const std::vector<T, Alloc>& opt) String option_to_string(const Vector<T, domain>& opt)
{ {
String res; String res;
for (size_t i = 0; i < opt.size(); ++i) for (size_t i = 0; i < opt.size(); ++i)
@ -47,8 +47,8 @@ String option_to_string(const std::vector<T, Alloc>& opt)
return res; return res;
} }
template<typename T, typename Alloc> template<typename T, MemoryDomain domain>
void option_from_string(StringView str, std::vector<T, Alloc>& opt) void option_from_string(StringView str, Vector<T, domain>& opt)
{ {
opt.clear(); opt.clear();
Vector<String> elems = split(str, list_separator, '\\'); Vector<String> elems = split(str, list_separator, '\\');
@ -60,8 +60,8 @@ void option_from_string(StringView str, std::vector<T, Alloc>& opt)
} }
} }
template<typename T, typename Alloc> template<typename T, MemoryDomain domain>
bool option_add(std::vector<T, Alloc>& opt, const std::vector<T, Alloc>& vec) bool option_add(Vector<T, domain>& opt, const Vector<T, domain>& vec)
{ {
std::copy(vec.begin(), vec.end(), back_inserter(opt)); std::copy(vec.begin(), vec.end(), back_inserter(opt));
return not vec.empty(); return not vec.empty();

View File

@ -14,7 +14,7 @@ class StaticRegister : public Register
public: public:
Register& operator=(ArrayView<String> values) override Register& operator=(ArrayView<String> values) override
{ {
m_content = std::vector<String>(values.begin(), values.end()); m_content = Vector<String>(values.begin(), values.end());
return *this; return *this;
} }
@ -26,7 +26,7 @@ public:
return ArrayView<String>(m_content); return ArrayView<String>(m_content);
} }
protected: protected:
std::vector<String> m_content; Vector<String> m_content;
static const String ms_empty; static const String ms_empty;
}; };

View File

@ -4,14 +4,14 @@
#include "register.hh" #include "register.hh"
#include "utils.hh" #include "utils.hh"
#include "unordered_map.hh" #include "unordered_map.hh"
#include "vector.hh"
#include <vector>
#include <functional> #include <functional>
namespace Kakoune namespace Kakoune
{ {
using RegisterRetriever = std::function<std::vector<String> (const Context&)>; using RegisterRetriever = std::function<Vector<String> (const Context&)>;
class RegisterManager : public Singleton<RegisterManager> class RegisterManager : public Singleton<RegisterManager>
{ {

View File

@ -76,7 +76,7 @@ public:
} }
template<typename T> template<typename T>
void write(const std::vector<T>& vec) void write(const Vector<T>& vec)
{ {
write(ArrayView<T>(vec)); write(ArrayView<T>(vec));
} }
@ -127,7 +127,7 @@ public:
} }
private: private:
std::vector<char> m_stream; Vector<char> m_stream;
int m_socket; int m_socket;
}; };
@ -174,10 +174,10 @@ String read<String>(int socket)
} }
template<typename T> template<typename T>
std::vector<T> read_vector(int socket) Vector<T> read_vector(int socket)
{ {
uint32_t size = read<uint32_t>(socket); uint32_t size = read<uint32_t>(socket);
std::vector<T> res; Vector<T> res;
res.reserve(size); res.reserve(size);
while (size--) while (size--)
res.push_back(read<T>(socket)); res.push_back(read<T>(socket));

View File

@ -57,7 +57,7 @@ private:
String m_session; String m_session;
std::unique_ptr<FDWatcher> m_listener; std::unique_ptr<FDWatcher> m_listener;
std::vector<std::unique_ptr<Accepter>> m_accepters; Vector<std::unique_ptr<Accepter>> m_accepters;
}; };
} }

View File

@ -6,8 +6,7 @@
#include "assert.hh" #include "assert.hh"
#ifdef SAFE_PTR_TRACK_CALLSTACKS #ifdef SAFE_PTR_TRACK_CALLSTACKS
#include "vector.hh"
#include <vector>
#include <algorithm> #include <algorithm>
#endif #endif
@ -155,7 +154,7 @@ private:
Backtrace bt; Backtrace bt;
}; };
mutable std::vector<Callstack> m_callstacks; mutable Vector<Callstack> m_callstacks;
#endif #endif
mutable int m_count; mutable int m_count;
#endif #endif

View File

@ -25,14 +25,14 @@ SelectionList::SelectionList(Buffer& buffer, Selection s)
: SelectionList(buffer, std::move(s), buffer.timestamp()) : SelectionList(buffer, std::move(s), buffer.timestamp())
{} {}
SelectionList::SelectionList(Buffer& buffer, std::vector<Selection> s, size_t timestamp) SelectionList::SelectionList(Buffer& buffer, Vector<Selection> s, size_t timestamp)
: m_buffer(&buffer), m_selections(std::move(s)), m_timestamp(timestamp) : m_buffer(&buffer), m_selections(std::move(s)), m_timestamp(timestamp)
{ {
kak_assert(size() > 0); kak_assert(size() > 0);
check_invariant(); check_invariant();
} }
SelectionList::SelectionList(Buffer& buffer, std::vector<Selection> s) SelectionList::SelectionList(Buffer& buffer, Vector<Selection> s)
: SelectionList(buffer, std::move(s), buffer.timestamp()) : 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; return last;
} }
void update_forward(ArrayView<Buffer::Change> changes, std::vector<Selection>& selections, size_t& main) void update_forward(ArrayView<Buffer::Change> changes, Vector<Selection>& selections, size_t& main)
{ {
ForwardChangesTracker changes_tracker; ForwardChangesTracker changes_tracker;
@ -221,7 +221,7 @@ void update_forward(ArrayView<Buffer::Change> changes, std::vector<Selection>& s
kak_assert(std::is_sorted(selections.begin(), selections.end(), compare_selections)); kak_assert(std::is_sorted(selections.begin(), selections.end(), compare_selections));
} }
void update_backward(ArrayView<Buffer::Change> changes, std::vector<Selection>& selections, size_t& main) void update_backward(ArrayView<Buffer::Change> changes, Vector<Selection>& selections, size_t& main)
{ {
ForwardChangesTracker changes_tracker; ForwardChangesTracker changes_tracker;
@ -258,9 +258,9 @@ void update_backward(ArrayView<Buffer::Change> changes, std::vector<Selection>&
} }
std::vector<Selection> compute_modified_ranges(Buffer& buffer, size_t timestamp) Vector<Selection> compute_modified_ranges(Buffer& buffer, size_t timestamp)
{ {
std::vector<Selection> ranges; Vector<Selection> ranges;
auto changes = buffer.changes_since(timestamp); auto changes = buffer.changes_since(timestamp);
auto change_it = changes.begin(); auto change_it = changes.begin();
while (change_it != changes.end()) while (change_it != changes.end())

View File

@ -6,7 +6,7 @@
namespace Kakoune namespace Kakoune
{ {
using CaptureList = std::vector<String>; using CaptureList = Vector<String>;
// A selection is a Selection, associated with a CaptureList // A selection is a Selection, associated with a CaptureList
struct Selection struct Selection
@ -70,8 +70,8 @@ struct SelectionList
{ {
SelectionList(Buffer& buffer, Selection s); SelectionList(Buffer& buffer, Selection s);
SelectionList(Buffer& buffer, Selection s, size_t timestamp); SelectionList(Buffer& buffer, Selection s, size_t timestamp);
SelectionList(Buffer& buffer, std::vector<Selection> s); SelectionList(Buffer& buffer, Vector<Selection> s);
SelectionList(Buffer& buffer, std::vector<Selection> s, size_t timestamp); SelectionList(Buffer& buffer, Vector<Selection> s, size_t timestamp);
void update(); void update();
@ -92,7 +92,7 @@ struct SelectionList
Selection& operator[](size_t i) { return m_selections[i]; } Selection& operator[](size_t i) { return m_selections[i]; }
const Selection& operator[](size_t i) const { return m_selections[i]; } const Selection& operator[](size_t i) const { return m_selections[i]; }
SelectionList& operator=(std::vector<Selection> list) SelectionList& operator=(Vector<Selection> list)
{ {
m_selections = std::move(list); m_selections = std::move(list);
m_main = size()-1; m_main = size()-1;
@ -102,11 +102,11 @@ struct SelectionList
return *this; return *this;
} }
using iterator = std::vector<Selection>::iterator; using iterator = Vector<Selection>::iterator;
iterator begin() { return m_selections.begin(); } iterator begin() { return m_selections.begin(); }
iterator end() { return m_selections.end(); } iterator end() { return m_selections.end(); }
using const_iterator = std::vector<Selection>::const_iterator; using const_iterator = Vector<Selection>::const_iterator;
const_iterator begin() const { return m_selections.begin(); } const_iterator begin() const { return m_selections.begin(); }
const_iterator end() const { return m_selections.end(); } const_iterator end() const { return m_selections.end(); }
@ -130,13 +130,13 @@ struct SelectionList
private: private:
size_t m_main = 0; size_t m_main = 0;
std::vector<Selection> m_selections; Vector<Selection> m_selections;
safe_ptr<Buffer> m_buffer; safe_ptr<Buffer> m_buffer;
size_t m_timestamp; size_t m_timestamp;
}; };
std::vector<Selection> compute_modified_ranges(Buffer& buffer, size_t timestamp); Vector<Selection> compute_modified_ranges(Buffer& buffer, size_t timestamp);
} }

View File

@ -31,9 +31,9 @@ Selection select_line(const Buffer& buffer, const Selection& selection)
Selection select_matching(const Buffer& buffer, const Selection& selection) Selection select_matching(const Buffer& buffer, const Selection& selection)
{ {
std::vector<Codepoint> matching_pairs = { '(', ')', '{', '}', '[', ']', '<', '>' }; Vector<Codepoint> matching_pairs = { '(', ')', '{', '}', '[', ']', '<', '>' };
Utf8Iterator it = buffer.iterator_at(selection.cursor()); Utf8Iterator it = buffer.iterator_at(selection.cursor());
std::vector<Codepoint>::iterator match = matching_pairs.end(); Vector<Codepoint>::iterator match = matching_pairs.end();
while (not is_eol(*it)) while (not is_eol(*it))
{ {
match = std::find(matching_pairs.begin(), matching_pairs.end(), *it); match = std::find(matching_pairs.begin(), matching_pairs.end(), *it);
@ -500,7 +500,7 @@ using RegexIt = RegexIterator<BufferIterator>;
void select_all_matches(SelectionList& selections, const Regex& regex) void select_all_matches(SelectionList& selections, const Regex& regex)
{ {
std::vector<Selection> result; Vector<Selection> result;
auto& buffer = selections.buffer(); auto& buffer = selections.buffer();
for (auto& sel : selections) 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) void split_selections(SelectionList& selections, const Regex& regex)
{ {
std::vector<Selection> result; Vector<Selection> result;
auto& buffer = selections.buffer(); auto& buffer = selections.buffer();
auto buf_end = buffer.end(); auto buf_end = buffer.end();
for (auto& sel : selections) for (auto& sel : selections)

View File

@ -128,7 +128,7 @@ String ShellManager::pipe(StringView input,
} }
const char* shell = "/bin/sh"; const char* shell = "/bin/sh";
auto cmdlinezstr = cmdline.zstr(); auto cmdlinezstr = cmdline.zstr();
std::vector<const char*> execparams = { shell, "-c", cmdlinezstr }; Vector<const char*> execparams = { shell, "-c", cmdlinezstr };
if (not params.empty()) if (not params.empty())
execparams.push_back(shell); execparams.push_back(shell);
for (auto& param : params) for (auto& param : params)

View File

@ -35,7 +35,7 @@ public:
String get_val(StringView name, const Context& context) const; String get_val(StringView name, const Context& context) const;
private: private:
std::vector<std::pair<Regex, EnvVarRetriever>> m_env_vars; Vector<std::pair<Regex, EnvVarRetriever>> m_env_vars;
}; };
} }

View File

@ -53,7 +53,7 @@ void test_buffer()
void test_undo_group_optimizer() void test_undo_group_optimizer()
{ {
std::vector<String> lines = { "allo ?\n", "mais que fais la police\n", " hein ?\n", " youpi\n" }; Vector<String> lines = { "allo ?\n", "mais que fais la police\n", " hein ?\n", " youpi\n" };
Buffer buffer("test", Buffer::Flags::None, lines); Buffer buffer("test", Buffer::Flags::None, lines);
auto pos = buffer.insert(buffer.end(), "kanaky\n"); auto pos = buffer.insert(buffer.end(), "kanaky\n");
buffer.erase(pos, buffer.end()); buffer.erase(pos, buffer.end());

View File

@ -39,6 +39,8 @@ public:
} }
int get_word_occurences(StringView word) const; int get_word_occurences(StringView word) const;
private:
using LineToWords = Vector<WordList, MemoryDomain::WordDB>;
struct WordInfo struct WordInfo
{ {
@ -46,8 +48,6 @@ public:
int refcount; int refcount;
}; };
using WordToInfo = UnorderedMap<InternedString, WordInfo, MemoryDomain::WordDB>; using WordToInfo = UnorderedMap<InternedString, WordInfo, MemoryDomain::WordDB>;
private:
using LineToWords = Vector<WordList, MemoryDomain::WordDB>;
void update_db(); void update_db();
void add_words(const WordList& words); void add_words(const WordList& words);