Skip to content

Commit

Permalink
tidy: Use the emplace_back function where possible.
Browse files Browse the repository at this point in the history
Instead of calling the STL push_back with an explicitly constructed
temporary object, the two calls can be collapsed into a single
emplace_back call.  This code is less verbose and potentially more
efficient.  These changes were suggested by the clang-tidy program.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-emplace.html
  • Loading branch information
linuxdude42 committed Mar 26, 2019
1 parent d57089c commit b87f6fd
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
11 changes: 5 additions & 6 deletions mythtv/libs/libmythtv/channelscan/scaninfo.cpp
Expand Up @@ -264,12 +264,11 @@ vector<ScanInfo> LoadScanList(void)

while (query.next())
{
list.push_back(
ScanInfo(query.value(0).toUInt(),
query.value(1).toUInt(),
query.value(2).toUInt(),
(bool) query.value(3).toUInt(),
MythDate::as_utc(query.value(4).toDateTime())));
list.emplace_back(query.value(0).toUInt(),
query.value(1).toUInt(),
query.value(2).toUInt(),
(bool) query.value(3).toUInt(),
MythDate::as_utc(query.value(4).toDateTime()));
}

return list;
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/recorders/asichannel.cpp
Expand Up @@ -12,7 +12,7 @@
ASIChannel::ASIChannel(TVRec *parent, const QString &device) :
DTVChannel(parent), m_device(device)
{
m_tuner_types.push_back(DTVTunerType(DTVTunerType::kTunerTypeASI));
m_tuner_types.emplace_back(DTVTunerType::kTunerTypeASI);
}

ASIChannel::~ASIChannel(void)
Expand Down
10 changes: 5 additions & 5 deletions mythtv/libs/libmythtv/recorders/hdhrstreamhandler.cpp
Expand Up @@ -318,22 +318,22 @@ bool HDHRStreamHandler::Open(void)
if (status_channel == "none")
{
LOG(VB_RECORD, LOG_INFO, LOC + "Cable card is not present");
m_tuner_types.push_back(DTVTunerType(DTVTunerType::kTunerTypeATSC));
m_tuner_types.emplace_back(DTVTunerType::kTunerTypeATSC);
}
else
{
LOG(VB_RECORD, LOG_INFO, LOC + "Cable card is present");
m_tuner_types.push_back(DTVTunerType(DTVTunerType::kTunerTypeOCUR));
m_tuner_types.emplace_back(DTVTunerType::kTunerTypeOCUR);
}
}
else if (QString(model).toLower().contains("dvb"))
{
m_tuner_types.push_back(DTVTunerType(DTVTunerType::kTunerTypeDVBT));
m_tuner_types.push_back(DTVTunerType(DTVTunerType::kTunerTypeDVBC));
m_tuner_types.emplace_back(DTVTunerType::kTunerTypeDVBT);
m_tuner_types.emplace_back(DTVTunerType::kTunerTypeDVBC);
}
else
{
m_tuner_types.push_back(DTVTunerType(DTVTunerType::kTunerTypeATSC));
m_tuner_types.emplace_back(DTVTunerType::kTunerTypeATSC);
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/tv_rec.cpp
Expand Up @@ -2355,7 +2355,7 @@ bool TVRec::CheckChannelPrefix(const QString &prefix,
fchanid.push_back(query.value(0).toUInt());
fchannum.push_back(query.value(1).toString());
finputid.push_back(query.value(2).toUInt());
fspacer.push_back(spacers[j]);
fspacer.emplace_back(spacers[j]);
#if DEBUG_CHANNEL_PREFIX
LOG(VB_GENERAL, LOG_DEBUG,
QString("(%1,%2) Adding %3 rec %4")
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/videoout_omx.cpp
Expand Up @@ -1148,8 +1148,8 @@ bool VideoOutputOMX::CreateBuffers(
std::vector<YUVInfo> yuvinfo;
for (uint i = 0; i < vbuffers.Size(); ++i)
{
yuvinfo.push_back(YUVInfo(video_dim_disp.width(),
video_dim_disp.height(), nBufferSize, pitches, offsets));
yuvinfo.emplace_back(video_dim_disp.width(), video_dim_disp.height(),
nBufferSize, pitches, offsets);
void *buf = av_malloc(nBufferSize + 64);
if (!buf)
{
Expand Down

0 comments on commit b87f6fd

Please sign in to comment.