Skip to content

Commit

Permalink
Use emplace_back() more.
Browse files Browse the repository at this point in the history
  • Loading branch information
wilx committed Dec 8, 2024
1 parent c15260a commit f16c0a0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/env.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ split_into_components(Container & components, tstring const & path,
while (it != end)
{
tstring::const_iterator sep = std::find_if (it, end, is_sep);
components.push_back (tstring (it, sep));
components.emplace_back (it, sep);
it = sep;
if (it != end)
++it;
Expand Down
4 changes: 2 additions & 2 deletions src/ndc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,11 @@ NDC::push_worker (StringType const & message)
{
DiagnosticContextStack* ptr = getPtr();
if (ptr->empty())
ptr->push_back( DiagnosticContext(message, nullptr) );
ptr->emplace_back (message, nullptr);
else
{
DiagnosticContext const & dc = ptr->back();
ptr->push_back( DiagnosticContext(message, &dc) );
ptr->emplace_back (message, &dc);
}
}

Expand Down
16 changes: 6 additions & 10 deletions src/patternlayout.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -767,9 +767,8 @@ PatternParser::parse()
break;
default:
if(! currentLiteral.empty ()) {
list.push_back
(std::unique_ptr<PatternConverter>(
new LiteralPatternConverter(currentLiteral)));
list.emplace_back (
new LiteralPatternConverter(currentLiteral));
//getLogLog().debug("Parsed LITERAL converter: \""
// +currentLiteral+"\".");
}
Expand Down Expand Up @@ -850,9 +849,7 @@ PatternParser::parse()
} // end while

if(! currentLiteral.empty ()) {
list.push_back(
std::unique_ptr<PatternConverter>(
new LiteralPatternConverter(currentLiteral)));
list.emplace_back(new LiteralPatternConverter(currentLiteral));
//getLogLog().debug("Parsed LITERAL converter: \""+currentLiteral+"\".");
}

Expand Down Expand Up @@ -1022,7 +1019,7 @@ PatternParser::finalizeConverter(tchar c)
pc = new LiteralPatternConverter(currentLiteral);
}

list.push_back(std::unique_ptr<PatternConverter>(pc));
list.emplace_back(pc);
currentLiteral.resize(0);
state = LITERAL_STATE;
formattingInfo.reset();
Expand Down Expand Up @@ -1098,10 +1095,9 @@ PatternLayout::init(const tstring& pattern_, unsigned ndcMaxDepth)
{
helpers::getLogLog().warn(
LOG4CPLUS_TEXT("PatternLayout pattern is empty. Using default..."));
parsedPattern.push_back (
std::unique_ptr<pattern::PatternConverter>(
parsedPattern.emplace_back (
new pattern::BasicPatternConverter(pattern::FormattingInfo(),
pattern::BasicPatternConverter::MESSAGE_CONVERTER)));
pattern::BasicPatternConverter::MESSAGE_CONVERTER));
}
}

Expand Down

0 comments on commit f16c0a0

Please sign in to comment.