Tweak regex constructor calls

This commit is contained in:
Maxime Coste 2015-07-25 11:15:03 +01:00
parent 6bed464105
commit 1af82e2e24
5 changed files with 12 additions and 13 deletions

View File

@ -405,7 +405,7 @@ public:
DynamicRegexHighlighter(RegexGetter regex_getter, FaceGetter face_getter)
: m_regex_getter(std::move(regex_getter)),
m_face_getter(std::move(face_getter)),
m_highlighter(Regex(), FacesSpec{}) {}
m_highlighter(Regex{}, FacesSpec{}) {}
void highlight(const Context& context, HighlightFlags flags, DisplayBuffer& display_buffer, BufferRange range)
{

View File

@ -483,7 +483,7 @@ public:
if (m_edit_filter)
{
m_edit_filter = false;
m_filter = Regex(".*");
m_filter = Regex{".*"};
m_filter_editor.reset("");
context().print_status(DisplayLine{});
}
@ -522,7 +522,7 @@ public:
m_filter_editor.handle_key(key);
auto search = ".*" + m_filter_editor.line() + ".*";
m_filter = Regex(search.begin(), search.end());
m_filter = Regex{search};
auto it = std::find_if(m_selected, m_choices.end(), match_filter);
if (it == m_choices.end())
it = std::find_if(m_choices.begin(), m_selected, match_filter);
@ -562,7 +562,7 @@ private:
m_callback(selected, MenuEvent::Select, context());
}
Regex m_filter = Regex(".*");
Regex m_filter = Regex{".*"};
bool m_edit_filter = false;
LineEditor m_filter_editor;
};

View File

@ -592,9 +592,8 @@ void regex_prompt(Context& context, const String prompt, T func)
if (event == PromptEvent::Validate)
context.push_jump();
Regex regex = str.empty() ? Regex{}
: Regex{str.begin(), str.end()};
func(std::move(regex), event, context);
func(str.empty() ? Regex{} : Regex{str}, event, context);
}
catch (regex_error& err)
{
@ -620,7 +619,7 @@ void search(Context& context, NormalParams)
regex_prompt(context, direction == Forward ? "search:" : "reverse search:",
[](Regex ex, PromptEvent event, Context& context) {
if (ex.empty())
ex = Regex{context.main_sel_register_value("/").str()};
ex = Regex{context.main_sel_register_value("/")};
else if (event == PromptEvent::Validate)
RegisterManager::instance()['/'] = ex.str();
if (not ex.empty() and not ex.str().empty())
@ -634,7 +633,7 @@ void search_next(Context& context, NormalParams params)
StringView str = context.main_sel_register_value("/");
if (not str.empty())
{
Regex ex{str.begin(), str.end()};
Regex ex{str};
do {
select_next_match<direction, mode>(context.buffer(), context.selections(), ex);
} while (--params.count > 0);
@ -679,7 +678,7 @@ void select_regex(Context& context, NormalParams)
{
regex_prompt(context, "select:", [](Regex ex, PromptEvent event, Context& context) {
if (ex.empty())
ex = Regex{context.main_sel_register_value("/").str()};
ex = Regex{context.main_sel_register_value("/")};
else if (event == PromptEvent::Validate)
RegisterManager::instance()['/'] = ex.str();
if (not ex.empty() and not ex.str().empty())
@ -691,7 +690,7 @@ void split_regex(Context& context, NormalParams)
{
regex_prompt(context, "split:", [](Regex ex, PromptEvent event, Context& context) {
if (ex.empty())
ex = Regex{context.main_sel_register_value("/").str()};
ex = Regex{context.main_sel_register_value("/")};
else if (event == PromptEvent::Validate)
RegisterManager::instance()['/'] = ex.str();
if (not ex.empty() and not ex.str().empty())

View File

@ -13,7 +13,7 @@ String option_to_string(const Regex& re)
void option_from_string(StringView str, Regex& re)
{
re = Regex{str.begin(), str.end()};
re = Regex{str};
}
}

View File

@ -138,7 +138,7 @@ std::pair<String, int> ShellManager::eval(
void ShellManager::register_env_var(StringView regex,
EnvVarRetriever retriever)
{
m_env_vars.push_back({ Regex(regex.begin(), regex.end()), std::move(retriever) });
m_env_vars.push_back({ Regex{regex}, std::move(retriever) });
}
String ShellManager::get_val(StringView name, const Context& context) const