remove make_pair
There are better alternatives with C++11. Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
5e46ad645a
commit
a00ebc65af
16
src/ast.cpp
16
src/ast.cpp
@ -232,33 +232,33 @@ static std::pair<source_range_t, const wchar_t *> find_block_open_keyword(const
|
||||
break;
|
||||
case type_t::for_header: {
|
||||
const auto *h = cursor->as<for_header_t>();
|
||||
return std::make_pair(h->kw_for.range, L"for loop");
|
||||
return {h->kw_for.range, L"for loop"};
|
||||
}
|
||||
case type_t::while_header: {
|
||||
const auto *h = cursor->as<while_header_t>();
|
||||
return std::make_pair(h->kw_while.range, L"while loop");
|
||||
return {h->kw_while.range, L"while loop"};
|
||||
}
|
||||
case type_t::function_header: {
|
||||
const auto *h = cursor->as<function_header_t>();
|
||||
return std::make_pair(h->kw_function.range, L"function definition");
|
||||
return {h->kw_function.range, L"function definition"};
|
||||
}
|
||||
case type_t::begin_header: {
|
||||
const auto *h = cursor->as<begin_header_t>();
|
||||
return std::make_pair(h->kw_begin.range, L"begin");
|
||||
return {h->kw_begin.range, L"begin"};
|
||||
}
|
||||
case type_t::if_statement: {
|
||||
const auto *h = cursor->as<if_statement_t>();
|
||||
return std::make_pair(h->if_clause.kw_if.range, L"if statement");
|
||||
return {h->if_clause.kw_if.range, L"if statement"};
|
||||
}
|
||||
case type_t::switch_statement: {
|
||||
const auto *h = cursor->as<switch_statement_t>();
|
||||
return std::make_pair(h->kw_switch.range, L"switch statement");
|
||||
return {h->kw_switch.range, L"switch statement"};
|
||||
}
|
||||
default:
|
||||
return std::make_pair(source_range_t{}, nullptr);
|
||||
return {source_range_t{}, nullptr};
|
||||
}
|
||||
}
|
||||
return std::make_pair(source_range_t{}, nullptr);
|
||||
return {source_range_t{}, nullptr};
|
||||
}
|
||||
|
||||
/// \return the decoration for this statement.
|
||||
|
@ -701,7 +701,7 @@ void completer_t::complete_cmd_desc(const wcstring &str) {
|
||||
// And once again I make sure the first character is uppercased because I like it that
|
||||
// way, and I get to decide these things.
|
||||
val.at(0) = towupper(val.at(0));
|
||||
lookup.insert(std::make_pair(std::move(key), std::move(val)));
|
||||
lookup.emplace(std::move(key), std::move(val));
|
||||
}
|
||||
|
||||
// Then do a lookup on every completion and if a match is found, change to the new
|
||||
|
@ -682,9 +682,9 @@ std::shared_ptr<owning_null_terminated_array_t> env_scoped_impl_t::create_export
|
||||
assert(var && "Variable should be present in uvars");
|
||||
// Note that std::map::insert does NOT overwrite a value already in the map,
|
||||
// which we depend on here.
|
||||
// Note: Using std::move around make_pair prevents the compiler from implementing
|
||||
// Note: Using std::move around emplace prevents the compiler from implementing
|
||||
// copy elision.
|
||||
vals.insert(std::make_pair(key, std::move(*var)));
|
||||
vals.emplace(key, std::move(*var));
|
||||
}
|
||||
|
||||
// Dorky way to add our single exported computed variable.
|
||||
|
@ -387,7 +387,7 @@ rgb_color_t highlight_color_resolver_t::resolve_spec(const highlight_spec_t &hig
|
||||
bool is_background,
|
||||
const environment_t &vars) {
|
||||
auto &cache = is_background ? bg_cache_ : fg_cache_;
|
||||
auto p = cache.insert(std::make_pair(highlight, rgb_color_t{}));
|
||||
auto p = cache.emplace(highlight, rgb_color_t{});
|
||||
auto iter = p.first;
|
||||
bool did_insert = p.second;
|
||||
if (did_insert) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user