mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
Change push_back → emplace_back (C++11)
This is mainly motivated by readability, so I only did a few select replacements.
This commit is contained in:
@@ -468,7 +468,7 @@ struct socket_observer_t
|
||||
}
|
||||
else
|
||||
{
|
||||
records.push_back(record_t(str));
|
||||
records.emplace_back(str);
|
||||
state = arguments;
|
||||
}
|
||||
D(DBF_RMateServer, bug("Got command ‘%s’\n", str.c_str()););
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace // encoding_list
|
||||
{
|
||||
std::string name, code;
|
||||
if(plist::get_key_path(*item, "name", name) && plist::get_key_path(*item, "code", code))
|
||||
res.push_back(charset_t(name, code));
|
||||
res.emplace_back(name, code);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ private:
|
||||
std::string const path = path::join(dir, entry->d_name);
|
||||
if(!includeHidden && (globs.exclude(path, entry->d_type == DT_DIR ? path::kPathItemDirectory : path::kPathItemFile) || (path::info(path) & path::flag::hidden)))
|
||||
continue;
|
||||
newItems.push_back(fs_item_t(buf.st_dev, entry, path));
|
||||
newItems.emplace_back(buf.st_dev, entry, path);
|
||||
}
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace bundles
|
||||
std::string name;
|
||||
oak::uuid_t uuid;
|
||||
if(plist::get_key_path(*it, kFieldName, name) && plist::get_key_path(*it, kFieldUUID, uuid))
|
||||
_required_bundles.push_back(required_bundle_t(name, uuid));
|
||||
_required_bundles.emplace_back(name, uuid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -136,14 +136,14 @@ namespace ng
|
||||
{
|
||||
if(range->empty())
|
||||
{
|
||||
_marks.push_back(mark_t(range->first, mark_t::kUnpairedMark));
|
||||
_marks.push_back(mark_t(range->first, mark_t::kEndMark));
|
||||
_marks.emplace_back(range->first, mark_t::kUnpairedMark);
|
||||
_marks.emplace_back(range->first, mark_t::kEndMark);
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t userInfo = (range->columnar ? kColumnar : 0) | (range->last < range->first ? kReversed : 0);
|
||||
_marks.push_back(mark_t(range->min(), mark_t::kBeginMark, userInfo));
|
||||
_marks.push_back(mark_t(range->max(), mark_t::kEndMark, userInfo));
|
||||
_marks.emplace_back(range->min(), mark_t::kBeginMark, userInfo);
|
||||
_marks.emplace_back(range->max(), mark_t::kEndMark, userInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -399,7 +399,7 @@ namespace ng
|
||||
auto node = _nodes.begin() + i;
|
||||
if(node->type() == kNodeTypeSoftBreak)
|
||||
{
|
||||
softlines.push_back(softline_t(firstOffset, x, y, metrics.baseline(ascent), metrics.line_height(ascent, descent, leading), first, i + (softBreaksOnNewline ? 0 : 1)));
|
||||
softlines.emplace_back(firstOffset, x, y, metrics.baseline(ascent), metrics.line_height(ascent, descent, leading), first, i + (softBreaksOnNewline ? 0 : 1));
|
||||
firstOffset = offset;
|
||||
x = (softBreaksOnNewline ? 0 : node->width());
|
||||
y += metrics.line_height(ascent, descent, leading);
|
||||
@@ -421,7 +421,7 @@ namespace ng
|
||||
offset += node->length();
|
||||
}
|
||||
|
||||
softlines.push_back(softline_t(firstOffset, x, y, metrics.baseline(ascent), metrics.line_height(ascent, descent, leading), first, _nodes.size()));
|
||||
softlines.emplace_back(firstOffset, x, y, metrics.baseline(ascent), metrics.line_height(ascent, descent, leading), first, _nodes.size());
|
||||
return softlines;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace plist
|
||||
std::vector<any_t>& ref = boost::get< std::vector<any_t> >(res = std::vector<any_t>());
|
||||
for(CFIndex i = 0; i < CFArrayGetCount(array); ++i)
|
||||
{
|
||||
ref.push_back(any_t());
|
||||
ref.emplace_back();
|
||||
convert_any(CFArrayGetValueAtIndex(array, i), ref.back());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,13 +225,13 @@ namespace path
|
||||
void glob_list_t::add_include_glob (std::string const& glob, kPathItemType itemType)
|
||||
{
|
||||
if(glob != NULL_STR)
|
||||
_globs.push_back(record_t(false, glob_t(glob, false), itemType));
|
||||
_globs.emplace_back(false, glob_t(glob, false), itemType);
|
||||
}
|
||||
|
||||
void glob_list_t::add_exclude_glob (std::string const& glob, kPathItemType itemType)
|
||||
{
|
||||
if(glob != NULL_STR)
|
||||
_globs.push_back(record_t(true, glob_t(glob, true), itemType));
|
||||
_globs.emplace_back(true, glob_t(glob, true), itemType);
|
||||
}
|
||||
|
||||
bool glob_list_t::include (std::string const& path, kPathItemType itemType, bool defaultResult) const
|
||||
|
||||
@@ -82,7 +82,7 @@ struct parse_context_t : parser_base_t
|
||||
std::string& text_node (nodes_t& nodes)
|
||||
{
|
||||
if(nodes.empty() || !boost::get<text_t>(&nodes.back()))
|
||||
nodes.push_back(text_t());
|
||||
nodes.emplace_back();
|
||||
return boost::get<text_t>(nodes.back()).text;
|
||||
}
|
||||
};
|
||||
@@ -215,11 +215,11 @@ bool parse_context_t::parse_case_change (nodes_t& nodes)
|
||||
{
|
||||
switch(it[-1])
|
||||
{
|
||||
case 'U': nodes.push_back(case_change_t(case_change::upper)); break;
|
||||
case 'L': nodes.push_back(case_change_t(case_change::lower)); break;
|
||||
case 'E': nodes.push_back(case_change_t(case_change::none)); break;
|
||||
case 'u': nodes.push_back(case_change_t(case_change::upper_next)); break;
|
||||
case 'l': nodes.push_back(case_change_t(case_change::lower_next)); break;
|
||||
case 'U': nodes.emplace_back(case_change::upper); break;
|
||||
case 'L': nodes.emplace_back(case_change::lower); break;
|
||||
case 'E': nodes.emplace_back(case_change::none); break;
|
||||
case 'u': nodes.emplace_back(case_change::upper_next); break;
|
||||
case 'l': nodes.emplace_back(case_change::lower_next); break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -307,9 +307,9 @@ bool parse_context_t::parse_placeholder (nodes_t& nodes)
|
||||
else if(parse_char("|"))
|
||||
{
|
||||
placeholder_choice_t res = { index };
|
||||
res.choices.push_back(nodes_t());
|
||||
res.choices.emplace_back();
|
||||
while(parse_format_string(",|", res.choices.back()) && it[-1] == ',')
|
||||
res.choices.push_back(nodes_t());
|
||||
res.choices.emplace_back();
|
||||
if(it[-1] == '|' && parse_char("}"))
|
||||
return nodes.push_back(res), true;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace scope
|
||||
bool rc = false;
|
||||
res.anchor_to_previous = parse_char(">") && ws();
|
||||
do {
|
||||
res.atoms.push_back(atom_t());
|
||||
res.atoms.emplace_back();
|
||||
if(!parse_atom(res.atoms.back()))
|
||||
{
|
||||
res.atoms.pop_back();
|
||||
|
||||
@@ -21,7 +21,7 @@ struct ini_file_t
|
||||
|
||||
void new_section (std::vector<std::string> const& names)
|
||||
{
|
||||
sections.push_back(section_t(names));
|
||||
sections.emplace_back(names);
|
||||
}
|
||||
|
||||
void insert_value (std::string const& name, std::string const& value)
|
||||
|
||||
@@ -129,15 +129,15 @@ namespace
|
||||
|
||||
if(section->names.empty())
|
||||
{
|
||||
res.push_back(section_t(variables));
|
||||
res.emplace_back(variables);
|
||||
}
|
||||
else
|
||||
{
|
||||
iterate(name, section->names)
|
||||
{
|
||||
if(is_scope_selector(*name))
|
||||
res.push_back(section_t(scope::selector_t(*name), variables));
|
||||
else res.push_back(section_t(path::glob_t(*name), variables));
|
||||
res.emplace_back(scope::selector_t(*name), variables);
|
||||
else res.emplace_back(path::glob_t(*name), variables);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ std::vector<theme_t::decomposed_style_t> theme_t::global_styles (scope::scope_t
|
||||
plist::any_t const& value = bundles::value_for_setting(colorKeys[i].name, scope, &item);
|
||||
if(item)
|
||||
{
|
||||
res.push_back(decomposed_style_t(item->scope_selector()));
|
||||
res.emplace_back(item->scope_selector());
|
||||
res.back().*(colorKeys[i].field) = read_color(plist::get<std::string>(value));
|
||||
}
|
||||
}
|
||||
@@ -102,7 +102,7 @@ std::vector<theme_t::decomposed_style_t> theme_t::global_styles (scope::scope_t
|
||||
plist::any_t const& value = bundles::value_for_setting(booleanKeys[i].name, scope, &item);
|
||||
if(item)
|
||||
{
|
||||
res.push_back(decomposed_style_t(item->scope_selector()));
|
||||
res.emplace_back(item->scope_selector());
|
||||
res.back().*(booleanKeys[i].field) = plist::is_true(value) ? bool_true : bool_false;
|
||||
}
|
||||
}
|
||||
@@ -111,7 +111,7 @@ std::vector<theme_t::decomposed_style_t> theme_t::global_styles (scope::scope_t
|
||||
plist::any_t const& fontNameValue = bundles::value_for_setting("fontName", scope, &fontNameItem);
|
||||
if(fontNameItem)
|
||||
{
|
||||
res.push_back(decomposed_style_t(fontNameItem->scope_selector()));
|
||||
res.emplace_back(fontNameItem->scope_selector());
|
||||
res.back().font_name = plist::get<std::string>(fontNameValue);
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ std::vector<theme_t::decomposed_style_t> theme_t::global_styles (scope::scope_t
|
||||
plist::any_t const& fontSizeValue = bundles::value_for_setting("fontSize", scope, &fontSizeItem);
|
||||
if(fontSizeItem)
|
||||
{
|
||||
res.push_back(decomposed_style_t(fontSizeItem->scope_selector()));
|
||||
res.emplace_back(fontSizeItem->scope_selector());
|
||||
res.back().font_size = read_font_size(plist::get<std::string>(fontSizeValue));
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace ng
|
||||
void undo_manager_t::will_replace (size_t from, size_t to, std::string const& str)
|
||||
{
|
||||
_records.erase(_records.begin() + _index, _records.end());
|
||||
_records.push_back(record_t(from, _buffer.substr(from, to), str, _pre_selection, _pre_revision));
|
||||
_records.emplace_back(from, _buffer.substr(from, to), str, _pre_selection, _pre_revision);
|
||||
_pre_selection = ranges_t();
|
||||
++_changes;
|
||||
++_index;
|
||||
|
||||
Reference in New Issue
Block a user