Skip to content

Commit

Permalink
tidy: Clean up code stripping dvd or bluray device names.
Browse files Browse the repository at this point in the history
The clang-tidy bugprone "branch clone" checker pointed out two places
where it appears that the bodies of an if/then/else clause were
duplicated.  It appears that this code was designed to strip a device
name from the front of the string, and replace a double "//" with a
single slash.  Rewrite these two clauses to simplify them.

https://clang.llvm.org/extra/clang-tidy/checks/bugprone-branch-clone.html
  • Loading branch information
linuxdude42 committed Nov 27, 2019
1 parent dbed56e commit f855c53
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions mythtv/libs/libmythtv/Bluray/bdringbuffer.cpp
Expand Up @@ -146,12 +146,12 @@ BDInfo::BDInfo(const QString &filename)
LOG(VB_PLAYBACK, LOG_INFO, QString("BDInfo: Trying %1").arg(filename));
QString name = filename;

if (name.startsWith("bd://"))
name.remove(0,4);
else if (name.startsWith("bd:/"))
name.remove(0,3);
else if (name.startsWith("bd:"))
if (name.startsWith("bd:"))
{
name.remove(0,3);
while (name.startsWith("//"))
name.remove(0,1);
}

// clean path filename
name = QDir(QDir::cleanPath(name)).canonicalPath();
Expand Down
10 changes: 5 additions & 5 deletions mythtv/libs/libmythtv/DVD/dvdringbuffer.cpp
Expand Up @@ -50,12 +50,12 @@ DVDInfo::DVDInfo(const QString &filename)
{
LOG(VB_PLAYBACK, LOG_INFO, QString("DVDInfo: Trying %1").arg(filename));
QString name = filename;
if (name.startsWith("dvd://"))
name.remove(0,5);
else if (name.startsWith("dvd:/"))
name.remove(0,4);
else if (name.startsWith("dvd:"))
if (name.startsWith("dvd:"))
{
name.remove(0,4);
while (name.startsWith("//"))
name.remove(0,1);
}

QByteArray fname = name.toLocal8Bit();
dvdnav_status_t res = dvdnav_open(&m_nav, fname.constData());
Expand Down

0 comments on commit f855c53

Please sign in to comment.