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{};
}
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)
res = m_parent->aliases_for(command);

View File

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

View File

@ -15,7 +15,7 @@
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)
: 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<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 });
@ -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<InternedString> new_lines;
Vector<InternedString> new_lines;
ByteCount start = 0;
for (ByteCount i = 0; i < content.length(); ++i)

View File

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

View File

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

View File

@ -39,7 +39,7 @@ Buffer* create_buffer_from_data(StringView data, StringView name,
pos = data.begin() + 3;
}
std::vector<String> lines;
Vector<String> 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<String>({"\n"_str}), 0);
buffer->reload(Vector<String>({"\n"_str}), 0);
}
else
buffer = new Buffer(std::move(name), Buffer::Flags::Fifo | Buffer::Flags::NoUndo);

View File

@ -48,8 +48,8 @@ public:
private:
String generate_name() const;
std::vector<std::unique_ptr<Client>> m_clients;
std::vector<WindowAndSelections> m_free_windows;
Vector<std::unique_ptr<Client>> m_clients;
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)
{
@ -402,7 +402,7 @@ void CommandManager::execute(StringView command_line,
return;
CharCoord command_coord;
std::vector<String> params;
Vector<String> 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<String> params;
Vector<String> params;
for (auto token_it = tokens.begin() + cmd_idx + 1;
token_it != tokens.end(); ++token_it)
params.push_back(token_it->content());

View File

@ -260,7 +260,7 @@ void quit()
{
if (not force and ClientManager::instance().count() == 1)
{
std::vector<String> names;
Vector<String> 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<String> highlighter_params;
Vector<String> highlighter_params;
for (; begin != parser.end(); ++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)
vars.push_back(parser[i]);
return vars;
@ -1255,9 +1255,9 @@ const CommandDesc menu_cmd = {
return;
}
std::vector<String> choices;
std::vector<String> commands;
std::vector<String> select_cmds;
Vector<String> choices;
Vector<String> commands;
Vector<String> select_cmds;
for (int i = 0; i < count; i += modulo)
{
choices.push_back(parser[i]);
@ -1424,14 +1424,14 @@ public:
: m_name(name)
{
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()
{ RegisterManager::instance()[m_name] = m_save; }
private:
std::vector<String> m_save;
Vector<String> m_save;
char m_name;
};

View File

@ -202,16 +202,16 @@ const SelectionList& Context::selections() const
return const_cast<Context&>(*this).selections();
}
std::vector<String> Context::selections_content() const
Vector<String> Context::selections_content() const
{
auto& buf = buffer();
std::vector<String> contents;
Vector<String> 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<Selection> sels)
void Context::set_selections(Vector<Selection> sels)
{
*m_selections = std::move(sels);
(*m_selections).check_invariant();

View File

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

View File

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

View File

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

View File

@ -207,7 +207,7 @@ public:
if (flags != HighlightFlags::Highlight)
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());
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<std::vector<LineAndFlag>>();
GlobalScope::instance().options()[option_name].get<Vector<LineAndFlag>>();
auto func = [=](const Context& context, HighlightFlags flags,
DisplayBuffer& display_buffer, BufferRange)
{
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;
for (auto& l : lines)

View File

@ -440,7 +440,7 @@ public:
private:
MenuCallback m_callback;
using ChoiceList = std::vector<String>;
using ChoiceList = Vector<String>;
const ChoiceList m_choices;
ChoiceList::const_iterator m_selected;
@ -476,13 +476,13 @@ String common_prefix(ArrayView<String> strings)
return res;
}
void history_push(std::vector<String>& history, StringView entry)
void history_push(Vector<String>& history, StringView entry)
{
if(entry.empty())
{
return;
}
std::vector<String>::iterator it;
Vector<String>::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<String>& history = ms_history[m_prompt];
Vector<String>& 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<String, std::vector<String>> ms_history;
std::vector<String>::iterator m_history_it;
static UnorderedMap<String, Vector<String>> ms_history;
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
{
@ -828,7 +828,7 @@ public:
}
else if (key == Key::Backspace)
{
std::vector<Selection> sels;
Vector<Selection> sels;
for (auto& sel : context().selections())
{
if (sel.cursor() == ByteCoord{0,0})
@ -841,7 +841,7 @@ public:
}
else if (key == Key::Delete)
{
std::vector<Selection> sels;
Vector<Selection> 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<Key> keys;
Vector<Key> keys;
swap(keys, m_last_insert.second);
// context.last_insert will be refilled by the new Insert
// this is very inefficient.

View File

@ -88,11 +88,11 @@ private:
friend class InputMode;
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);
using Insertion = std::pair<InsertMode, std::vector<Key>>;
using Insertion = std::pair<InsertMode, Vector<Key>>;
Insertion m_last_insert = {InsertMode::Insert, {}};
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 column = get_column(m_context.buffer(), tabstop,
m_completions.begin);
std::vector<String> menu_entries;
Vector<String> 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<InsertCompleterDescList>();
std::vector<StringView> option_names;
Vector<StringView> option_names;
for (auto& completer : completers)
{
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))
{
const LineChange change(buf_change);

View File

@ -3,8 +3,7 @@
#include "units.hh"
#include "utils.hh"
#include <vector>
#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<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()
{
using StringList = std::vector<String>;
using StringList = Vector<String>;
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<String> result;
Vector<String> 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<String>({ "./", "/usr/include" }));
Vector<String>({ "./", "/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<String> params;
Vector<String> 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<StringView> files;
Vector<StringView> 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<StringView> files;
Vector<StringView> files;
for (size_t i = 0; i < parser.positional_count(); ++i)
files.emplace_back(parser[i]);
StringView session;

View File

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

View File

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

View File

@ -211,7 +211,7 @@ void goto_commands(Context& context, NormalParams params)
if (contains(filename, c))
return;
auto paths = context.options()["path"].get<std::vector<String>>();
auto paths = context.options()["path"].get<Vector<String>>();
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<String> strings;
Vector<String> strings;
for (auto& sel : selections)
{
CharCount count = char_length(buffer, sel);
@ -334,7 +334,7 @@ template<Codepoint (*func)(Codepoint)>
void for_each_char(Context& context, NormalParams)
{
ScopedEdition edition(context);
std::vector<String> sels = context.selections_content();
Vector<String> 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<String> strings;
Vector<String> 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<ByteCount> offsets;
Vector<ByteCount> 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<Selection> result;
Vector<Selection> result;
for (auto& selection : selections)
{
ByteCount pos = 0;
@ -655,7 +655,7 @@ void search_next(Context& context, NormalParams params)
template<bool smart>
void use_selection_as_search_pattern(Context& context, NormalParams)
{
std::vector<String> patterns;
Vector<String> 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<Selection> res;
Vector<Selection> 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<Selection> selections;
Vector<Selection> 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<Selection> keep;
Vector<Selection> 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<Selection> keep;
Vector<Selection> 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<Selection> sels;
Vector<Selection> 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<Selection> sels;
Vector<Selection> 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<int>();
std::vector<std::vector<const Selection*>> columns;
Vector<Vector<const Selection*>> 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<LineCount> lines;
Vector<LineCount> 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<int>();
const CharCount tabstop = params.count == 0 ? opt_tabstop : params.count;
std::vector<Selection> tabs;
std::vector<String> spaces;
Vector<Selection> tabs;
Vector<String> 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<int>();
const CharCount tabstop = params.count == 0 ? opt_tabstop : params.count;
std::vector<Selection> spaces;
Vector<Selection> spaces;
for (auto& sel : context.selections())
{
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 = ':';
template<typename T, typename Alloc>
String option_to_string(const std::vector<T, Alloc>& opt)
template<typename T, MemoryDomain domain>
String option_to_string(const Vector<T, domain>& opt)
{
String res;
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;
}
template<typename T, typename Alloc>
void option_from_string(StringView str, std::vector<T, Alloc>& opt)
template<typename T, MemoryDomain domain>
void option_from_string(StringView str, Vector<T, domain>& opt)
{
opt.clear();
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>
bool option_add(std::vector<T, Alloc>& opt, const std::vector<T, Alloc>& vec)
template<typename T, MemoryDomain domain>
bool option_add(Vector<T, domain>& opt, const Vector<T, domain>& vec)
{
std::copy(vec.begin(), vec.end(), back_inserter(opt));
return not vec.empty();

View File

@ -14,7 +14,7 @@ class StaticRegister : public Register
public:
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;
}
@ -26,7 +26,7 @@ public:
return ArrayView<String>(m_content);
}
protected:
std::vector<String> m_content;
Vector<String> m_content;
static const String ms_empty;
};

View File

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

View File

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

View File

@ -57,7 +57,7 @@ private:
String m_session;
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"
#ifdef SAFE_PTR_TRACK_CALLSTACKS
#include <vector>
#include "vector.hh"
#include <algorithm>
#endif
@ -155,7 +154,7 @@ private:
Backtrace bt;
};
mutable std::vector<Callstack> m_callstacks;
mutable Vector<Callstack> m_callstacks;
#endif
mutable int m_count;
#endif

View File

@ -25,14 +25,14 @@ SelectionList::SelectionList(Buffer& buffer, Selection s)
: 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)
{
kak_assert(size() > 0);
check_invariant();
}
SelectionList::SelectionList(Buffer& buffer, std::vector<Selection> s)
SelectionList::SelectionList(Buffer& buffer, Vector<Selection> 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<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;
@ -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));
}
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;
@ -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 change_it = changes.begin();
while (change_it != changes.end())

View File

@ -6,7 +6,7 @@
namespace Kakoune
{
using CaptureList = std::vector<String>;
using CaptureList = Vector<String>;
// 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<Selection> s);
SelectionList(Buffer& buffer, std::vector<Selection> s, size_t timestamp);
SelectionList(Buffer& buffer, Vector<Selection> s);
SelectionList(Buffer& buffer, Vector<Selection> 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<Selection> list)
SelectionList& operator=(Vector<Selection> list)
{
m_selections = std::move(list);
m_main = size()-1;
@ -102,11 +102,11 @@ struct SelectionList
return *this;
}
using iterator = std::vector<Selection>::iterator;
using iterator = Vector<Selection>::iterator;
iterator begin() { return m_selections.begin(); }
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 end() const { return m_selections.end(); }
@ -130,13 +130,13 @@ struct SelectionList
private:
size_t m_main = 0;
std::vector<Selection> m_selections;
Vector<Selection> m_selections;
safe_ptr<Buffer> m_buffer;
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)
{
std::vector<Codepoint> matching_pairs = { '(', ')', '{', '}', '[', ']', '<', '>' };
Vector<Codepoint> matching_pairs = { '(', ')', '{', '}', '[', ']', '<', '>' };
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))
{
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)
{
std::vector<Selection> result;
Vector<Selection> 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<Selection> result;
Vector<Selection> result;
auto& buffer = selections.buffer();
auto buf_end = buffer.end();
for (auto& sel : selections)

View File

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

View File

@ -35,7 +35,7 @@ public:
String get_val(StringView name, const Context& context) const;
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()
{
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);
auto pos = buffer.insert(buffer.end(), "kanaky\n");
buffer.erase(pos, buffer.end());

View File

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