Skip to content

Commit

Permalink
tidy: Replace x.length() in a boolean context with !x.isEmpty().
Browse files Browse the repository at this point in the history
These instances were pointed out by clang-tidy's "implicit boolean
conversion" check.  Similar to the replacement of x.size() with
!x.empty(), replacing x.length() with !x.empty() also seems like it
would be more efficient and also shows clearer intent.

https://clang.llvm.org/extra/clang-tidy/checks/readability-container-size-empty.html
  • Loading branch information
linuxdude42 committed Mar 19, 2019
1 parent be7a6d9 commit 5a931b7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion mythtv/libs/libmythbase/mythmiscutil.cpp
Expand Up @@ -923,7 +923,7 @@ void setHttpProxy(void)
// via myth_system(command), by setting HTTP_PROXY
QString url;

if (p.user().length())
if (!p.user().isEmpty())
url = "http://%1:%2@%3:%4",
url = url.arg(p.user()).arg(p.password());
else
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythmetadata/metadatacommon.cpp
Expand Up @@ -818,7 +818,7 @@ void CreateMetadataXMLItem(MetadataLookup *lookup,
lookup->GetRuntimeSeconds())));
}

if (lookup->GetCertification().size())
if (!lookup->GetCertification().isEmpty())
AddCertifications(lookup, item, docroot);
if (!lookup->GetCategories().empty())
AddCategories(lookup, item, docroot);
Expand Down
6 changes: 3 additions & 3 deletions mythtv/libs/libmythmetadata/parentalcontrols.cpp
Expand Up @@ -177,7 +177,7 @@ namespace
i <= ParentalLevel::plHigh && i.good(); ++i)
{
pws::const_iterator p = m_passwords.find(i.GetLevel());
if (p != m_passwords.end() && p->second.length())
if (p != m_passwords.end() && !p->second.isEmpty())
ret.push_back(p->second);
}

Expand All @@ -191,7 +191,7 @@ namespace
i >= ParentalLevel::plLow && i.good(); --i)
{
pws::const_iterator p = m_passwords.find(i.GetLevel());
if (p != m_passwords.end() && p->second.length())
if (p != m_passwords.end() && !p->second.isEmpty())
{
ret = p->second;
break;
Expand Down Expand Up @@ -255,7 +255,7 @@ class ParentalLevelChangeCheckerPrivate : public QObject
// The assumption is that if you password protected lower levels,
// and a higher level does not have a password it is something
// you've overlooked (rather than intended).
if (!m_pm.FirstAtOrBelow(which_level.GetLevel()).length())
if (m_pm.FirstAtOrBelow(which_level.GetLevel()).isEmpty())
return true;

// See if we recently (and successfully) asked for a password
Expand Down
6 changes: 3 additions & 3 deletions mythtv/libs/libmythmetadata/videometadata.cpp
Expand Up @@ -827,7 +827,7 @@ void VideoMetadataImp::updateGenres()
genre_list::iterator genre = m_genres.begin();
while (genre != m_genres.end())
{
if (genre->second.trimmed().length())
if (!genre->second.trimmed().isEmpty())
{
genre->first = VideoGenre::getGenre().add(genre->second);
VideoGenreMap::getGenreMap().add(m_id, genre->first);
Expand All @@ -848,7 +848,7 @@ void VideoMetadataImp::updateCountries()
country_list::iterator country = m_countries.begin();
while (country != m_countries.end())
{
if (country->second.trimmed().length())
if (!country->second.trimmed().isEmpty())
{
country->first = VideoCountry::getCountry().add(country->second);
VideoCountryMap::getCountryMap().add(m_id, country->first);
Expand All @@ -869,7 +869,7 @@ void VideoMetadataImp::updateCast()
cast_list::iterator cast = m_cast.begin();
while (cast != m_cast.end())
{
if (cast->second.trimmed().length())
if (!cast->second.trimmed().isEmpty())
{
cast->first = VideoCast::GetCast().add(cast->second);
VideoCastMap::getCastMap().add(m_id, cast->first);
Expand Down
2 changes: 1 addition & 1 deletion mythtv/programs/mythfrontend/customedit.cpp
Expand Up @@ -726,7 +726,7 @@ void CustomEdit::storeClicked(void)
QString msg = QString("%1: %2\n\n").arg(tr("Current Example"))
.arg(m_titleEdit->GetText());

if (m_subtitleEdit->GetText().length())
if (!m_subtitleEdit->GetText().isEmpty())
msg += m_subtitleEdit->GetText() + "\n\n";

msg += m_descriptionEdit->GetText();
Expand Down

0 comments on commit 5a931b7

Please sign in to comment.