Skip to content

Commit

Permalink
clazy: Combine multiple calls to QString::arg in mythfilldatabase.
Browse files Browse the repository at this point in the history
Each call to QString::arg causes the Qt libraries to scan the string
to find the lowest numbered place marker, and it causes a memory
allocate to store the resulting integrated string. Consecutive calls
to ::arg with string arguments can be combined into a single call,
thus reducing the number of required string scans and (more
importantly) memory allocations.
  • Loading branch information
linuxdude42 committed Apr 22, 2021
1 parent 6eaf44e commit b9d978f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions mythtv/programs/mythfilldatabase/channeldata.cpp
Expand Up @@ -253,7 +253,7 @@ void ChannelData::handleChannels(int id, ChannelInfoList *chanlist) const
{
LOG(VB_GENERAL, LOG_INFO,
QString("Converting old xmltvid (%1) to new (%2)")
.arg((*i).m_oldXmltvId).arg((*i).m_xmltvId));
.arg((*i).m_oldXmltvId, (*i).m_xmltvId));

query.prepare("UPDATE channel "
"SET xmltvid = :NEWXMLTVID"
Expand All @@ -273,7 +273,7 @@ void ChannelData::handleChannels(int id, ChannelInfoList *chanlist) const
{
LOG(VB_XMLTV, LOG_DEBUG,
QString("Match found for xmltvid %1 to channel %2 (%3)")
.arg((*i).m_xmltvId).arg(dbChan.m_name).arg(dbChan.m_chanId));
.arg((*i).m_xmltvId, dbChan.m_name, QString::number(dbChan.m_chanId)));
if (m_interactive)
{

Expand Down
11 changes: 5 additions & 6 deletions mythtv/programs/mythfilldatabase/filldata.cpp
Expand Up @@ -136,14 +136,13 @@ bool FillData::GrabData(const Source& source, int offset)
if (query1.next())
configfile = query1.value(0).toString();
else
configfile = QString("%1/%2.xmltv").arg(GetConfDir())
.arg(source.name);
configfile = QString("%1/%2.xmltv").arg(GetConfDir(), source.name);

LOG(VB_GENERAL, LOG_INFO,
QString("XMLTV config file is: %1").arg(configfile));

QString command = QString("nice %1 --config-file '%2' --output %3")
.arg(xmltv_grabber).arg(configfile).arg(filename);
.arg(xmltv_grabber, configfile, filename);


if (source.xmltvgrabber_prefmethod != "allatonce" || m_noAllAtOnce)
Expand Down Expand Up @@ -313,9 +312,9 @@ bool FillData::Run(SourceList &sourcelist)
continue;
}

LOG(VB_GENERAL, LOG_INFO, sidStr.arg((*it).id)
.arg((*it).name)
.arg(xmltv_grabber));
LOG(VB_GENERAL, LOG_INFO, sidStr.arg(QString::number((*it).id),
(*it).name,
xmltv_grabber));

query.prepare(
"SELECT COUNT(chanid) FROM channel "
Expand Down
5 changes: 2 additions & 3 deletions mythtv/programs/mythfilldatabase/main.cpp
Expand Up @@ -467,7 +467,7 @@ int main(int argc, char *argv[])

LOG(VB_GENERAL, LOG_INFO,
QString(" %1 -> %2 (part %3 of %4)")
.arg(orig_programid).arg(new_programid)
.arg(orig_programid, new_programid)
.arg(partnum).arg(parttotal));

repl.bindValue(":NEWID", new_programid);
Expand All @@ -478,8 +478,7 @@ int main(int argc, char *argv[])
{
LOG(VB_GENERAL, LOG_INFO,
QString("Fudging programid from '%1' to '%2'")
.arg(orig_programid)
.arg(new_programid));
.arg(orig_programid, new_programid));
}
else
found += repl.numRowsAffected();
Expand Down

0 comments on commit b9d978f

Please sign in to comment.