diff --git a/.clang-tidy b/.clang-tidy index 77733f59c80..87b8a90427f 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -18,5 +18,6 @@ Checks: "\ performance-unnecessary-value-param,\ readability-container-contains,\ readability-container-data-pointer,\ + readability-container-size-empty,\ " HeaderFilterRegex: '(^|/)(tools|xbmc)/' diff --git a/xbmc/Autorun.cpp b/xbmc/Autorun.cpp index 0fcceecc25b..3762b40e519 100644 --- a/xbmc/Autorun.cpp +++ b/xbmc/Autorun.cpp @@ -300,7 +300,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, if (StringUtils::EqualsNoCase(name, "HVDVD_TS") && bAllowVideo && (options.bypassSettings || bAutorunDVDs)) { - if (hddvdname == "") + if (hddvdname.empty()) { CLog::Log(LOGINFO,"HD DVD: Checking for ifo."); // find Video Manager or Title Set Information @@ -349,7 +349,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, items.Copy (sitems); sitems.Clear(); } - if (hddvdname != "") + if (!hddvdname.empty()) { CFileItem item(URIUtils::AddFileToFolder(phddvdItem->GetPath(), hddvdname), false); item.SetLabel(CServiceBroker::GetMediaManager().GetDiskLabel(strDrive)); diff --git a/xbmc/CueDocument.cpp b/xbmc/CueDocument.cpp index ee072135b3e..0365977b8ce 100644 --- a/xbmc/CueDocument.cpp +++ b/xbmc/CueDocument.cpp @@ -134,10 +134,7 @@ public: return !line.empty(); } - bool ready() const override - { - return m_data.size() > 0; - } + bool ready() const override { return !m_data.empty(); } private: std::string m_data; diff --git a/xbmc/FileItemList.h b/xbmc/FileItemList.h index 0cf2fc92411..04a5f1be8a0 100644 --- a/xbmc/FileItemList.h +++ b/xbmc/FileItemList.h @@ -151,7 +151,7 @@ public: void AddSortMethod(const SortDescription& sortDescription, int buttonLabel, const LABEL_MASKS& labelMasks); - bool HasSortDetails() const { return m_sortDetails.size() != 0; } + bool HasSortDetails() const { return !m_sortDetails.empty(); } const std::vector& GetSortDetails() const { return m_sortDetails; } /*! \brief Specify whether this list should be sorted with folders separate from files diff --git a/xbmc/LangInfo.cpp b/xbmc/LangInfo.cpp index e015d8af846..3be2fd87898 100644 --- a/xbmc/LangInfo.cpp +++ b/xbmc/LangInfo.cpp @@ -238,7 +238,7 @@ void CLangInfo::CRegion::SetTimeZone(const std::string& strTimeZone) void CLangInfo::CRegion::SetGlobalLocale() { std::string strLocale; - if (m_strRegionLocaleName.length() > 0) + if (!m_strRegionLocaleName.empty()) { #ifdef TARGET_WINDOWS std::string strLang, strRegion; diff --git a/xbmc/TextureDatabase.cpp b/xbmc/TextureDatabase.cpp index 6647f99f296..f7e13445d44 100644 --- a/xbmc/TextureDatabase.cpp +++ b/xbmc/TextureDatabase.cpp @@ -333,7 +333,7 @@ std::vector CTextureDatabase::GetOldestCachedImages(unsigned int ma bool CTextureDatabase::SetKeepCachedImages(const std::vector& imagesToKeep) { - if (!imagesToKeep.size()) + if (imagesToKeep.empty()) return true; std::string sql = "UPDATE texture SET lastlibrarycheck=CURRENT_TIMESTAMP WHERE url IN ("; diff --git a/xbmc/URL.cpp b/xbmc/URL.cpp index b934e7569e2..9c6b133a1c2 100644 --- a/xbmc/URL.cpp +++ b/xbmc/URL.cpp @@ -63,7 +63,8 @@ void CURL::Parse(std::string strURL1) // format 3: drive:directoryandfile // // first need 2 check if this is a protocol or just a normal drive & path - if (!strURL.size()) return ; + if (strURL.empty()) + return; if (strURL == "?") return; // form is format 1 or 2 @@ -291,7 +292,7 @@ void CURL::Parse(std::string strURL1) if (IsProtocol("musicdb") || IsProtocol("videodb") || IsProtocol("sources") || IsProtocol("pvr")) { - if (m_strHostName != "" && m_strFileName != "") + if (!m_strHostName.empty() && !m_strFileName.empty()) { m_strFileName = StringUtils::Format("{}/{}", m_strHostName, m_strFileName); m_strHostName = ""; @@ -353,7 +354,7 @@ void CURL::SetOptions(std::string strOptions) { m_strOptions.clear(); m_options.Clear(); - if( strOptions.length() > 0) + if (!strOptions.empty()) { if(strOptions[0] == '?' || strOptions[0] == '#' || @@ -372,7 +373,7 @@ void CURL::SetProtocolOptions(std::string strOptions) { m_strProtocolOptions.clear(); m_protocolOptions.Clear(); - if (strOptions.length() > 0) + if (!strOptions.empty()) { if (strOptions[0] == '|') m_strProtocolOptions = std::move(strOptions).substr(1); @@ -558,9 +559,9 @@ std::string CURL::GetWithoutUserDetails(bool redact) const } strURL += m_strFileName; - if( m_strOptions.length() > 0 ) + if (!m_strOptions.empty()) strURL += m_strOptions; - if( m_strProtocolOptions.length() > 0 ) + if (!m_strProtocolOptions.empty()) strURL += "|"+m_strProtocolOptions; return strURL; @@ -650,7 +651,8 @@ bool CURL::IsFileOnly(const std::string &url) bool CURL::IsFullPath(const std::string &url) { - if (url.size() && url[0] == '/') return true; // /foo/bar.ext + if (!url.empty() && url[0] == '/') + return true; // /foo/bar.ext if (url.find("://") != std::string::npos) return true; // foo://bar.ext if (url.size() > 1 && url[1] == ':') return true; // c:\\foo\\bar\\bar.ext if (StringUtils::StartsWith(url, "\\\\")) return true; // \\UNC\path\to\file diff --git a/xbmc/Util.cpp b/xbmc/Util.cpp index c999b3a1896..1ea1f58a488 100644 --- a/xbmc/Util.cpp +++ b/xbmc/Util.cpp @@ -714,7 +714,7 @@ bool CUtil::GetDirectoryName(const std::string& strFileName, std::string& strDes size_t iPos = strDescription.find_last_of("/\\"); if (iPos != std::string::npos) strDescription = strDescription.substr(iPos + 1); - else if (strDescription.size() <= 0) + else if (strDescription.empty()) strDescription = strFName; return true; } @@ -1214,7 +1214,7 @@ void CUtil::SplitParams(const std::string ¶mString, std::vector parameter.erase(quotaPos, 1); } } - if (!parameter.empty() || parameters.size()) + if (!parameter.empty() || !parameters.empty()) parameters.push_back(parameter); } diff --git a/xbmc/addons/AddonDatabase.cpp b/xbmc/addons/AddonDatabase.cpp index 1c12d30c5e2..bc03bcf8b9d 100644 --- a/xbmc/addons/AddonDatabase.cpp +++ b/xbmc/addons/AddonDatabase.cpp @@ -1269,7 +1269,7 @@ bool IsAddonImageChecked(const std::string& addonImage, std::vector CAddonDatabase::GetUsedImages( const std::vector& imagesToCheck) const { - if (!imagesToCheck.size()) + if (imagesToCheck.empty()) return {}; VECADDONS allAddons; diff --git a/xbmc/addons/AddonInstaller.cpp b/xbmc/addons/AddonInstaller.cpp index d48b6ddd92d..52f48577847 100644 --- a/xbmc/addons/AddonInstaller.cpp +++ b/xbmc/addons/AddonInstaller.cpp @@ -312,7 +312,7 @@ std::vector CAddonInstaller::RemoveOrphanedDepsRecursively() const std::vector removedItems; auto toRemove = CServiceBroker::GetAddonMgr().GetOrphanedDependencies(); - while (toRemove.size() > 0) + while (!toRemove.empty()) { for (const auto& dep : toRemove) { @@ -1257,7 +1257,7 @@ bool CAddonUnInstallJob::DoWork() { const auto removedItems = CAddonInstaller::GetInstance().RemoveOrphanedDepsRecursively(); - if (removedItems.size() > 0) + if (!removedItems.empty()) { CLog::Log(LOGINFO, "CAddonUnInstallJob[{}]: removed orphaned dependencies ({})", m_addon->ID(), StringUtils::Join(removedItems, ", ")); diff --git a/xbmc/addons/AddonManager.cpp b/xbmc/addons/AddonManager.cpp index ecf8e026636..451eaaf9c1c 100644 --- a/xbmc/addons/AddonManager.cpp +++ b/xbmc/addons/AddonManager.cpp @@ -495,7 +495,7 @@ bool CAddonMgr::GetAddonsInternal(AddonType type, addons.emplace_back(std::move(addon)); } } - return addons.size() > 0; + return !addons.empty(); } bool CAddonMgr::GetIncompatibleEnabledAddonInfos(std::vector& incompatible) const diff --git a/xbmc/addons/AddonSystemSettings.cpp b/xbmc/addons/AddonSystemSettings.cpp index 30f3aaf66b0..e4cf134b8d5 100644 --- a/xbmc/addons/AddonSystemSettings.cpp +++ b/xbmc/addons/AddonSystemSettings.cpp @@ -69,7 +69,7 @@ void CAddonSystemSettings::OnSettingAction(const std::shared_ptr using namespace KODI::MESSAGING::HELPERS; const auto removedItems = CAddonInstaller::GetInstance().RemoveOrphanedDepsRecursively(); - if (removedItems.size() > 0) + if (!removedItems.empty()) { const auto message = StringUtils::Format(g_localizeStrings.Get(36641), StringUtils::Join(removedItems, ", ")); diff --git a/xbmc/addons/Skin.cpp b/xbmc/addons/Skin.cpp index 06339798560..f9cff2043e8 100644 --- a/xbmc/addons/Skin.cpp +++ b/xbmc/addons/Skin.cpp @@ -222,7 +222,7 @@ void CSkinInfo::Start() if (!LoadUserSettings()) CLog::Log(LOGWARNING, "CSkinInfo: failed to load skin settings"); - if (!m_resolutions.size()) + if (m_resolutions.empty()) { // try falling back to whatever resolutions exist in the directory CFileItemList items; CDirectory::GetDirectory(Path(), items, "", DIR_FLAG_NO_FILE_DIRS); diff --git a/xbmc/application/AppParamParser.cpp b/xbmc/application/AppParamParser.cpp index 2eb6c4ab20a..4d214c9b818 100644 --- a/xbmc/application/AppParamParser.cpp +++ b/xbmc/application/AppParamParser.cpp @@ -110,7 +110,7 @@ void CAppParamParser::ParseArg(const std::string &arg) m_params->SetTestMode(true); else if (arg.substr(0, 11) == "--settings=") m_params->SetSettingsFile(arg.substr(11)); - else if (arg.length() != 0 && arg[0] != '-') + else if (!arg.empty() && arg[0] != '-') { const CFileItemPtr item = std::make_shared(arg); item->SetPath(arg); diff --git a/xbmc/application/Application.cpp b/xbmc/application/Application.cpp index d66aec2d3a2..77191a3e745 100644 --- a/xbmc/application/Application.cpp +++ b/xbmc/application/Application.cpp @@ -1526,7 +1526,7 @@ void CApplication::OnApplicationMessage(ThreadMessage* pMsg) case TMSG_START_ANDROID_ACTIVITY: { #if defined(TARGET_ANDROID) - if (pMsg->params.size()) + if (!pMsg->params.empty()) { CXBMCApp::StartActivity(pMsg->params[0], pMsg->params.size() > 1 ? pMsg->params[1] : "", pMsg->params.size() > 2 ? pMsg->params[2] : "", diff --git a/xbmc/cores/AudioEngine/Sinks/pipewire/AESinkPipewire.cpp b/xbmc/cores/AudioEngine/Sinks/pipewire/AESinkPipewire.cpp index 1235a699462..81360ce41ae 100644 --- a/xbmc/cores/AudioEngine/Sinks/pipewire/AESinkPipewire.cpp +++ b/xbmc/cores/AudioEngine/Sinks/pipewire/AESinkPipewire.cpp @@ -332,7 +332,7 @@ void CAESinkPipewire::EnumerateDevicesEx(AEDeviceInfoList& list, bool force) } auto& channels = node->GetChannels(); - if (channels.size() < 1) + if (channels.empty()) continue; for (const auto& channel : channels) diff --git a/xbmc/cores/AudioEngine/Utils/AEBitstreamPacker.cpp b/xbmc/cores/AudioEngine/Utils/AEBitstreamPacker.cpp index 05ee3f6cced..eb9bd409309 100644 --- a/xbmc/cores/AudioEngine/Utils/AEBitstreamPacker.cpp +++ b/xbmc/cores/AudioEngine/Utils/AEBitstreamPacker.cpp @@ -167,7 +167,7 @@ void CAEBitstreamPacker::PackEAC3(CAEStreamInfo &info, uint8_t* data, int size) { /* multiple frames needed to achieve 6 blocks as required by IEC 61937-3:2007 */ - if (m_eac3.size() == 0) + if (m_eac3.empty()) m_eac3.resize(EAC3_MAX_BURST_PAYLOAD_SIZE); unsigned int newsize = m_eac3Size + size; diff --git a/xbmc/cores/AudioEngine/Utils/AEELDParser.cpp b/xbmc/cores/AudioEngine/Utils/AEELDParser.cpp index f7d3043d5e5..1ebc8b7b63b 100644 --- a/xbmc/cores/AudioEngine/Utils/AEELDParser.cpp +++ b/xbmc/cores/AudioEngine/Utils/AEELDParser.cpp @@ -115,7 +115,7 @@ void CAEELDParser::Parse(const uint8_t *data, size_t length, CAEDeviceInfo& info [](char c) { return !std::isspace(c); }) .base(), header.monitor_name.end()); - if (header.monitor_name.length() > 0) + if (!header.monitor_name.empty()) { info.m_displayNameExtra.append(" "); info.m_displayNameExtra.append(header.monitor_name); diff --git a/xbmc/cores/ExternalPlayer/ExternalPlayer.cpp b/xbmc/cores/ExternalPlayer/ExternalPlayer.cpp index dca25fce58c..e032c126aa0 100644 --- a/xbmc/cores/ExternalPlayer/ExternalPlayer.cpp +++ b/xbmc/cores/ExternalPlayer/ExternalPlayer.cpp @@ -549,7 +549,7 @@ bool CExternalPlayer::SetPlayerState(const std::string& state) bool CExternalPlayer::Initialize(TiXmlElement* pConfig) { XMLUtils::GetString(pConfig, "filename", m_filename); - if (m_filename.length() > 0) + if (!m_filename.empty()) { CLog::Log(LOGINFO, "ExternalPlayer Filename: {}", m_filename); } diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecTX3G.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecTX3G.cpp index 91f1c9d691b..0dbb57c7c9c 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecTX3G.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecTX3G.cpp @@ -137,7 +137,7 @@ OverlayMessage CDVDOverlayCodecTX3G::Decode(DemuxPacket* pPacket) else if (boxType == BOX_TYPE_STYL) { // Parse the contained StyleRecords - if (styleRecords.size() != 0) + if (!styleRecords.empty()) { CLog::Log(LOGDEBUG, "{} - Found additional TextStyleBox, skipping", __FUNCTION__); sampleData.SkipChars(boxSize - MP4_BOX_HEADER_SIZE); diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp index 5aff0f4d167..2bcba31b9ae 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp @@ -1707,9 +1707,8 @@ void CMixer::StateMachine(int signal, Protocol *port, Message *msg) m_state = M_TOP_CONFIGURED_STEP1; m_bStateMachineSelfTrigger = true; } - else if (!m_outputSurfaces.empty() && - m_config.stats->IsDraining() && - m_mixerInput.size() >= 1) + else if (!m_outputSurfaces.empty() && m_config.stats->IsDraining() && + !m_mixerInput.empty()) { CVdpauDecodedPicture pic; pic.DVDPic.SetParams(m_mixerInput[0].DVDPic); @@ -2664,8 +2663,7 @@ void CMixer::FiniCycle() // NVidia recommends num_ref + 5 size_t surfToKeep = 5; - if (m_mixerInput.size() > 0 && - (m_mixerInput[0].videoSurface == VDP_INVALID_HANDLE)) + if (!m_mixerInput.empty() && (m_mixerInput[0].videoSurface == VDP_INVALID_HANDLE)) surfToKeep = 1; while (m_mixerInput.size() > surfToKeep) diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp index b1e8e08692a..6d0d0f513fa 100644 --- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp +++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp @@ -253,7 +253,7 @@ bool CDVDDemuxFFmpeg::Open(const std::shared_ptr& pInput, bool m_pInput = pInput; strFile = m_pInput->GetFileName(); - if (m_pInput->GetContent().length() > 0) + if (!m_pInput->GetContent().empty()) { std::string content = m_pInput->GetContent(); StringUtils::ToLower(content); @@ -798,7 +798,7 @@ AVDictionary* CDVDDemuxFFmpeg::GetFFMpegOptionsFromInput() } // Any other headers that need to be sent would be user defined and should be prefixed // by a `!`. We mask these values so we don't log anything we shouldn't - else if (name.length() > 0 && name[0] == '!') + else if (!name.empty() && name[0] == '!') { CLog::Log(LOGDEBUG, "CDVDDemuxFFmpeg::GetFFMpegOptionsFromInput() adding user custom header option " diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxVobsub.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxVobsub.cpp index 0e8bb11dbc7..bba57b5488b 100644 --- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxVobsub.cpp +++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxVobsub.cpp @@ -52,7 +52,7 @@ bool CDVDDemuxVobsub::Open(const std::string& filename, int source, const std::s return false; std::string vobsub = subfilename; - if ( vobsub == "") + if (vobsub.empty()) { vobsub = filename; vobsub.erase(vobsub.rfind('.'), vobsub.size()); diff --git a/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamFFmpeg.cpp index c8baf1bb870..24d45510162 100644 --- a/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamFFmpeg.cpp +++ b/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamFFmpeg.cpp @@ -117,7 +117,7 @@ std::string CDVDInputStreamFFmpeg::GetFileName() url.IsProtocol("rtmps")) { std::vector opts = StringUtils::Split(url.Get(), " "); - if (opts.size() > 0) + if (!opts.empty()) { return opts.front(); } diff --git a/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitleParserSubrip.cpp b/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitleParserSubrip.cpp index 0bc8808ddfb..c1d8b3a2a17 100644 --- a/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitleParserSubrip.cpp +++ b/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitleParserSubrip.cpp @@ -36,7 +36,7 @@ bool CDVDSubtitleParserSubrip::Open(CDVDStreamInfo& hints) { StringUtils::Trim(line); - if (line.length() > 0) + if (!line.empty()) { char sep; int hh1, mm1, ss1, ms1, hh2, mm2, ss2, ms2; @@ -63,7 +63,7 @@ bool CDVDSubtitleParserSubrip::Open(CDVDStreamInfo& hints) if (line.empty()) break; - if (convText.size() > 0) + if (!convText.empty()) convText += "\n"; TagConv.ConvertLine(line); convText += line; diff --git a/xbmc/cores/VideoPlayer/VideoPlayer.cpp b/xbmc/cores/VideoPlayer/VideoPlayer.cpp index 5a57ddf865a..d907521f76c 100644 --- a/xbmc/cores/VideoPlayer/VideoPlayer.cpp +++ b/xbmc/cores/VideoPlayer/VideoPlayer.cpp @@ -5408,10 +5408,10 @@ void CVideoPlayer::GetVideoStreamInfo(int streamId, VideoStreamInfo& info) const } const SelectionStream& s = m_content.m_selectionStreams.Get(STREAM_VIDEO, streamId); - if (s.language.length() > 0) + if (!s.language.empty()) info.language = s.language; - if (s.name.length() > 0) + if (!s.name.empty()) info.name = s.name; m_renderManager.GetVideoRect(info.SrcRect, info.DestRect, info.VideoRect); diff --git a/xbmc/cores/VideoPlayer/VideoPlayerSubtitle.cpp b/xbmc/cores/VideoPlayer/VideoPlayerSubtitle.cpp index 701a5f48299..94cbe52a45e 100644 --- a/xbmc/cores/VideoPlayer/VideoPlayerSubtitle.cpp +++ b/xbmc/cores/VideoPlayer/VideoPlayerSubtitle.cpp @@ -121,7 +121,7 @@ bool CVideoPlayerSubtitle::OpenStream(CDVDStreamInfo &hints, std::string &filena m_streaminfo = hints; // okey check if this is a filesubtitle - if(filename.size() && filename != "dvd" ) + if (!filename.empty() && filename != "dvd") { m_pSubtitleFileParser.reset(CDVDFactorySubtitle::CreateParser(filename)); if (!m_pSubtitleFileParser) diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/OverlayRendererGL.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/OverlayRendererGL.cpp index 7f2debce85b..ec507379ff6 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/OverlayRendererGL.cpp +++ b/xbmc/cores/VideoPlayer/VideoRenderers/OverlayRendererGL.cpp @@ -270,7 +270,7 @@ COverlayGlyphGL::~COverlayGlyphGL() void COverlayGlyphGL::Render(SRenderState& state) { - if ((m_texture == 0) || (m_vertex.size() == 0)) + if ((m_texture == 0) || (m_vertex.empty())) return; glEnable(GL_BLEND); diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/OverlayRendererGLES.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/OverlayRendererGLES.cpp index 4f4b39b038a..4efacf50a94 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/OverlayRendererGLES.cpp +++ b/xbmc/cores/VideoPlayer/VideoRenderers/OverlayRendererGLES.cpp @@ -328,7 +328,7 @@ COverlayGlyphGLES::~COverlayGlyphGLES() void COverlayGlyphGLES::Render(SRenderState& state) { - if ((m_texture == 0) || (m_vertex.size() == 0)) + if ((m_texture == 0) || (m_vertex.empty())) return; glEnable(GL_BLEND); diff --git a/xbmc/cores/paplayer/PAPlayer.cpp b/xbmc/cores/paplayer/PAPlayer.cpp index 799eac657ec..987d1f0aa49 100644 --- a/xbmc/cores/paplayer/PAPlayer.cpp +++ b/xbmc/cores/paplayer/PAPlayer.cpp @@ -257,17 +257,18 @@ void PAPlayer::UpdateCrossfadeTime(const CFileItem& file) if (m_upcomingCrossfadeMS) { - if (!m_currentStream || (file.HasMusicInfoTag() && - !CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool( - CSettings::SETTING_MUSICPLAYER_CROSSFADEALBUMTRACKS) && - m_currentStream->m_fileItem->HasMusicInfoTag() && - (m_currentStream->m_fileItem->GetMusicInfoTag()->GetAlbum() != "") && - (m_currentStream->m_fileItem->GetMusicInfoTag()->GetAlbum() == - file.GetMusicInfoTag()->GetAlbum()) && - (m_currentStream->m_fileItem->GetMusicInfoTag()->GetDiscNumber() == - file.GetMusicInfoTag()->GetDiscNumber()) && - (m_currentStream->m_fileItem->GetMusicInfoTag()->GetTrackNumber() == - file.GetMusicInfoTag()->GetTrackNumber() - 1))) + if (!m_currentStream || + (file.HasMusicInfoTag() && + !CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool( + CSettings::SETTING_MUSICPLAYER_CROSSFADEALBUMTRACKS) && + m_currentStream->m_fileItem->HasMusicInfoTag() && + (!m_currentStream->m_fileItem->GetMusicInfoTag()->GetAlbum().empty()) && + (m_currentStream->m_fileItem->GetMusicInfoTag()->GetAlbum() == + file.GetMusicInfoTag()->GetAlbum()) && + (m_currentStream->m_fileItem->GetMusicInfoTag()->GetDiscNumber() == + file.GetMusicInfoTag()->GetDiscNumber()) && + (m_currentStream->m_fileItem->GetMusicInfoTag()->GetTrackNumber() == + file.GetMusicInfoTag()->GetTrackNumber() - 1))) { //do not crossfade when playing consecutive albumtracks m_upcomingCrossfadeMS = 0; diff --git a/xbmc/cores/playercorefactory/PlayerCoreFactory.cpp b/xbmc/cores/playercorefactory/PlayerCoreFactory.cpp index 0ee8c65676e..3dea2513fc5 100644 --- a/xbmc/cores/playercorefactory/PlayerCoreFactory.cpp +++ b/xbmc/cores/playercorefactory/PlayerCoreFactory.cpp @@ -305,7 +305,7 @@ std::string CPlayerCoreFactory::GetDefaultPlayer(const CFileItem& item) const std::string CPlayerCoreFactory::SelectPlayerDialog(const std::vector&players, float posX, float posY) const { CContextButtons choices; - if (players.size()) + if (!players.empty()) { //Add default player std::string strCaption = players[0]; diff --git a/xbmc/cores/playercorefactory/PlayerSelectionRule.cpp b/xbmc/cores/playercorefactory/PlayerSelectionRule.cpp index 3bee50aa061..bcca4cdc089 100644 --- a/xbmc/cores/playercorefactory/PlayerSelectionRule.cpp +++ b/xbmc/cores/playercorefactory/PlayerSelectionRule.cpp @@ -69,9 +69,8 @@ void CPlayerSelectionRule::Initialize(TiXmlElement* pRule) m_videoAspect = XMLUtils::GetAttribute(pRule, "videoaspect"); m_hdrType = XMLUtils::GetAttribute(pRule, "hdrtype"); - m_bStreamDetails = m_audioCodec.length() > 0 || m_audioChannels.length() > 0 || - m_videoCodec.length() > 0 || m_videoResolution.length() > 0 || - m_videoAspect.length() > 0 || m_hdrType.length() > 0; + m_bStreamDetails = !m_audioCodec.empty() || !m_audioChannels.empty() || !m_videoCodec.empty() || + !m_videoResolution.empty() || !m_videoAspect.empty() || !m_hdrType.empty(); if (m_bStreamDetails && !CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_MYVIDEOS_EXTRACTFLAGS)) { @@ -174,7 +173,7 @@ void CPlayerSelectionRule::GetPlayers(const CFileItem& item, std::vectorsize() == 0) // Filling columns name + if (fields_object->empty()) // Filling columns name { const unsigned int ncols = result.record_header.size(); fields_object->resize(ncols); @@ -1773,7 +1773,7 @@ void MysqlDataset::fill_fields() } //Filling result - if (result.records.size() != 0) + if (!result.records.empty()) { const sql_record* row = result.records[frecno]; if (row) @@ -2015,7 +2015,7 @@ void MysqlDataset::open(const std::string& sql) void MysqlDataset::open() { - if (select_sql.size()) + if (!select_sql.empty()) { query(select_sql); } @@ -2039,7 +2039,7 @@ void MysqlDataset::cancel() { if ((ds_state == dsInsert) || (ds_state == dsEdit)) { - if (result.record_header.size()) + if (!result.record_header.empty()) ds_state = dsSelect; else ds_state = dsInactive; diff --git a/xbmc/dbwrappers/sqlitedataset.cpp b/xbmc/dbwrappers/sqlitedataset.cpp index 819667d7a3a..6522915a42a 100644 --- a/xbmc/dbwrappers/sqlitedataset.cpp +++ b/xbmc/dbwrappers/sqlitedataset.cpp @@ -167,7 +167,7 @@ int callback(void* res_ptr, int ncol, char** result, char** cols) { result_set* r = static_cast(res_ptr); - if (!r->record_header.size()) + if (r->record_header.empty()) { r->record_header.reserve(ncol); for (int i = 0; i < ncol; i++) @@ -380,7 +380,7 @@ bool SqliteDatabase::exists(void) snprintf(sqlcmd, sizeof(sqlcmd), "SELECT * FROM sqlite_master"); if ((last_err = sqlite3_exec(getHandle(), sqlcmd, &callback, &res, NULL)) == SQLITE_OK) { - bRet = (res.records.size() > 0); + bRet = (!res.records.empty()); } return bRet; @@ -794,7 +794,7 @@ void SqliteDataset::fill_fields() (result.records.size() < (unsigned int)frecno)) return; - if (fields_object->size() == 0) // Filling columns name + if (fields_object->empty()) // Filling columns name { const unsigned int ncols = result.record_header.size(); fields_object->resize(ncols); @@ -807,7 +807,7 @@ void SqliteDataset::fill_fields() } //Filling result - if (result.records.size() != 0) + if (!result.records.empty()) { const sql_record* row = result.records[frecno]; if (row) @@ -998,7 +998,7 @@ void SqliteDataset::open(const std::string& sql) void SqliteDataset::open() { - if (select_sql.size()) + if (!select_sql.empty()) { query(select_sql); } @@ -1022,7 +1022,7 @@ void SqliteDataset::cancel() { if ((ds_state == dsInsert) || (ds_state == dsEdit)) { - if (result.record_header.size()) + if (!result.record_header.empty()) ds_state = dsSelect; else ds_state = dsInactive; diff --git a/xbmc/dialogs/GUIDialogContextMenu.cpp b/xbmc/dialogs/GUIDialogContextMenu.cpp index 2f7602a50d1..ce7b7db07b5 100644 --- a/xbmc/dialogs/GUIDialogContextMenu.cpp +++ b/xbmc/dialogs/GUIDialogContextMenu.cpp @@ -117,7 +117,7 @@ void CGUIDialogContextMenu::OnInitWindow() void CGUIDialogContextMenu::SetupButtons() { - if (!m_buttons.size()) + if (m_buttons.empty()) return; // disable the template button control diff --git a/xbmc/dialogs/GUIDialogExtendedProgressBar.cpp b/xbmc/dialogs/GUIDialogExtendedProgressBar.cpp index 9243e82a9e3..f7e536f3bf2 100644 --- a/xbmc/dialogs/GUIDialogExtendedProgressBar.cpp +++ b/xbmc/dialogs/GUIDialogExtendedProgressBar.cpp @@ -114,7 +114,7 @@ void CGUIDialogExtendedProgressBar::UpdateState(unsigned int currentTime) } } - if (!m_handles.size()) + if (m_handles.empty()) { Close(false, 0, true, false); return; diff --git a/xbmc/dialogs/GUIDialogFileBrowser.cpp b/xbmc/dialogs/GUIDialogFileBrowser.cpp index b4f0d87b43a..a88998ba867 100644 --- a/xbmc/dialogs/GUIDialogFileBrowser.cpp +++ b/xbmc/dialogs/GUIDialogFileBrowser.cpp @@ -449,7 +449,7 @@ void CGUIDialogFileBrowser::Update(const std::string &strDirectory) std::string strPath2 = m_Directory->GetPath(); URIUtils::RemoveSlashAtEnd(strPath2); - strSelectedItem = m_history.GetSelectedItem(strPath2==""?"empty":strPath2); + strSelectedItem = m_history.GetSelectedItem(strPath2.empty() ? "empty" : strPath2); bool bSelectedFound = false; for (int i = 0; i < m_vecItems->Size(); ++i) @@ -822,7 +822,7 @@ bool CGUIDialogFileBrowser::ShowAndGetFileList(const std::vector& bool confirmed(browser->IsConfirmed()); if (confirmed) { - if (browser->m_markedPath.size()) + if (!browser->m_markedPath.empty()) path = browser->m_markedPath; else path.push_back(browser->m_selectedPath); @@ -910,7 +910,7 @@ bool CGUIDialogFileBrowser::ShowAndGetSource( void CGUIDialogFileBrowser::SetSources(const std::vector& shares) { m_shares = shares; - if (!m_shares.size() && m_addSourceType.empty()) + if (m_shares.empty() && m_addSourceType.empty()) CServiceBroker::GetMediaManager().GetLocalDrives(m_shares); m_rootDir.SetSources(m_shares); } diff --git a/xbmc/dialogs/GUIDialogKeyboardGeneric.cpp b/xbmc/dialogs/GUIDialogKeyboardGeneric.cpp index 02344bda41b..8757155e32c 100644 --- a/xbmc/dialogs/GUIDialogKeyboardGeneric.cpp +++ b/xbmc/dialogs/GUIDialogKeyboardGeneric.cpp @@ -440,7 +440,7 @@ void CGUIDialogKeyboardGeneric::NormalCharacter(const std::string &ch) void CGUIDialogKeyboardGeneric::Backspace() { - if (m_codingtable && m_hzcode.length() > 0) + if (m_codingtable && !m_hzcode.empty()) { std::wstring tmp; g_charsetConverter.utf8ToW(m_hzcode, tmp); @@ -579,7 +579,7 @@ void CGUIDialogKeyboardGeneric::OnDeinitWindow(int nextWindowID) void CGUIDialogKeyboardGeneric::MoveCursor(int iAmount) { - if (m_codingtable && m_words.size()) + if (m_codingtable && !m_words.empty()) ChangeWordList(iAmount); else { diff --git a/xbmc/dialogs/GUIDialogMediaSource.cpp b/xbmc/dialogs/GUIDialogMediaSource.cpp index db9e56b3fbc..d38898a8011 100644 --- a/xbmc/dialogs/GUIDialogMediaSource.cpp +++ b/xbmc/dialogs/GUIDialogMediaSource.cpp @@ -291,7 +291,10 @@ void CGUIDialogMediaSource::OnPathBrowse(int item) extraShares.push_back(share1); } - if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetString(CSettings::SETTING_AUDIOCDS_RECORDINGPATH) != "") + if (!CServiceBroker::GetSettingsComponent() + ->GetSettings() + ->GetString(CSettings::SETTING_AUDIOCDS_RECORDINGPATH) + .empty()) { share1.strPath = "special://recordings/"; share1.strName = g_localizeStrings.Get(21883); @@ -391,7 +394,10 @@ void CGUIDialogMediaSource::OnPathBrowse(int item) #endif share1.m_ignore = true; - if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetString(CSettings::SETTING_DEBUG_SCREENSHOTPATH) != "") + if (!CServiceBroker::GetSettingsComponent() + ->GetSettings() + ->GetString(CSettings::SETTING_DEBUG_SCREENSHOTPATH) + .empty()) { share1.strPath = "special://screenshots/"; share1.strName = g_localizeStrings.Get(20008); @@ -406,7 +412,8 @@ void CGUIDialogMediaSource::OnPathBrowse(int item) { // nothing to add } - if (CGUIDialogFileBrowser::ShowAndGetSource(path, allowNetworkShares, extraShares.size() == 0 ? NULL : &extraShares)) + if (CGUIDialogFileBrowser::ShowAndGetSource(path, allowNetworkShares, + extraShares.empty() ? NULL : &extraShares)) { if (item < m_paths->Size()) // if the skin does funky things, m_paths may have been cleared m_paths->Get(item)->SetPath(path); @@ -506,7 +513,7 @@ void CGUIDialogMediaSource::SetShare(const CMediaSource &share) CFileItemPtr item(new CFileItem(share.vecPaths[i], true)); m_paths->Add(item); } - if (0 == share.vecPaths.size()) + if (share.vecPaths.empty()) { CFileItemPtr item(new CFileItem("", true)); m_paths->Add(item); diff --git a/xbmc/dialogs/GUIDialogSelect.cpp b/xbmc/dialogs/GUIDialogSelect.cpp index 0f99e2765ba..3cdf2f8abc8 100644 --- a/xbmc/dialogs/GUIDialogSelect.cpp +++ b/xbmc/dialogs/GUIDialogSelect.cpp @@ -212,7 +212,7 @@ void CGUIDialogSelect::SetItems(const CFileItemList& pList) int CGUIDialogSelect::GetSelectedItem() const { - return m_selectedItems.size() > 0 ? m_selectedItems[0] : -1; + return !m_selectedItems.empty() ? m_selectedItems[0] : -1; } const CFileItemPtr CGUIDialogSelect::GetSelectedFileItem() const diff --git a/xbmc/dialogs/GUIDialogSmartPlaylistEditor.cpp b/xbmc/dialogs/GUIDialogSmartPlaylistEditor.cpp index ddfd0d9d0a1..32f684ed902 100644 --- a/xbmc/dialogs/GUIDialogSmartPlaylistEditor.cpp +++ b/xbmc/dialogs/GUIDialogSmartPlaylistEditor.cpp @@ -502,7 +502,7 @@ void CGUIDialogSmartPlaylistEditor::OnInitWindow() if (type == allowedType) allowed = true; } - if (!allowed && allowedTypes.size()) + if (!allowed && !allowedTypes.empty()) m_playlist.SetType(ConvertType(allowedTypes[0])); UpdateButtons(); diff --git a/xbmc/filesystem/CurlFile.cpp b/xbmc/filesystem/CurlFile.cpp index 2bb049a33d5..ba6cea7cd1b 100644 --- a/xbmc/filesystem/CurlFile.cpp +++ b/xbmc/filesystem/CurlFile.cpp @@ -600,7 +600,7 @@ void CCurlFile::SetCommonOptions(CReadState* state, bool failOnError /* = true * } // allow passive mode for ftp - if( m_ftpport.length() > 0 ) + if (!m_ftpport.empty()) g_curlInterface.easy_setopt(h, CURLOPT_FTPPORT, m_ftpport.c_str()); else g_curlInterface.easy_setopt(h, CURLOPT_FTPPORT, NULL); @@ -612,13 +612,13 @@ void CCurlFile::SetCommonOptions(CReadState* state, bool failOnError /* = true * g_curlInterface.easy_setopt(h, CURLOPT_FTP_SKIP_PASV_IP, 1); // setup Accept-Encoding if requested - if (m_acceptencoding.length() > 0) + if (!m_acceptencoding.empty()) g_curlInterface.easy_setopt(h, CURLOPT_ACCEPT_ENCODING, m_acceptencoding == "all" ? "" : m_acceptencoding.c_str()); if (!m_acceptCharset.empty()) SetRequestHeader("Accept-Charset", m_acceptCharset); - if (m_userAgent.length() > 0) + if (!m_userAgent.empty()) g_curlInterface.easy_setopt(h, CURLOPT_USERAGENT, m_userAgent.c_str()); else /* set some default agent as shoutcast doesn't return proper stuff otherwise */ g_curlInterface.easy_setopt(h, CURLOPT_USERAGENT, CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_userAgent.c_str()); @@ -641,7 +641,7 @@ void CCurlFile::SetCommonOptions(CReadState* state, bool failOnError /* = true * if (!userpass.empty()) g_curlInterface.easy_setopt(h, CURLOPT_PROXYUSERPWD, userpass.c_str()); } - if (m_customrequest.length() > 0) + if (!m_customrequest.empty()) { g_curlInterface.easy_setopt(h, CURLOPT_CUSTOMREQUEST, m_customrequest.c_str()); if (StringUtils::CompareNoCase(m_customrequest, "HEAD") == 0) @@ -927,7 +927,7 @@ void CCurlFile::ParseAndCorrectUrl(CURL &url2) } else { - if (name.length() > 0 && name[0] == '!') + if (!name.empty() && name[0] == '!') { SetRequestHeader(it.first.substr(1), value); CLog::LogFC(LOGDEBUG, LOGCURL, "<{}> Adding custom header option '{}: ***********'", @@ -951,7 +951,7 @@ void CCurlFile::ParseAndCorrectUrl(CURL &url2) // Unset the protocol options to have an url without protocol options url2.SetProtocolOptions(""); - if (m_username.length() > 0 && m_password.length() > 0) + if (!m_username.empty() && !m_password.empty()) m_url = url2.GetWithoutUserDetails(); else m_url = url2.Get(); diff --git a/xbmc/filesystem/FTPDirectory.cpp b/xbmc/filesystem/FTPDirectory.cpp index 51af9e5a649..95b02809b71 100644 --- a/xbmc/filesystem/FTPDirectory.cpp +++ b/xbmc/filesystem/FTPDirectory.cpp @@ -53,7 +53,7 @@ bool CFTPDirectory::GetDirectory(const CURL& url2, CFileItemList &items) CFTPParse parse; if (parse.FTPParse(strBuffer)) { - if( parse.getName().length() == 0 ) + if (parse.getName().empty()) continue; if( parse.getFlagtrycwd() == 0 && parse.getFlagtryretr() == 0 ) diff --git a/xbmc/filesystem/FTPParse.cpp b/xbmc/filesystem/FTPParse.cpp index 563fb2a194c..8996860ca46 100644 --- a/xbmc/filesystem/FTPParse.cpp +++ b/xbmc/filesystem/FTPParse.cpp @@ -135,7 +135,7 @@ void CFTPParse::setTime(const std::string& str) time_struct.tm_min = std::stol(minute); /* set the second if given*/ - if (second.length() > 0) + if (!second.empty()) time_struct.tm_sec = std::stol(second); } // Regex to read MSDOS time format diff --git a/xbmc/filesystem/HTTPDirectory.cpp b/xbmc/filesystem/HTTPDirectory.cpp index 5fdcd193d6e..99e7e5f3f66 100644 --- a/xbmc/filesystem/HTTPDirectory.cpp +++ b/xbmc/filesystem/HTTPDirectory.cpp @@ -74,7 +74,7 @@ bool CHTTPDirectory::GetDirectory(const CURL& url, CFileItemList &items) /* read response from server into string buffer */ std::string strBuffer; - if (http.ReadData(strBuffer) && strBuffer.length() > 0) + if (http.ReadData(strBuffer) && !strBuffer.empty()) { /* if Content-Length is found and its not text/html, URL is pointing to file so don't treat URL as HTTPDirectory */ if (!http.GetHttpHeader().GetValue("Content-Length").empty() && @@ -179,7 +179,7 @@ bool CHTTPDirectory::GetDirectory(const CURL& url, CFileItemList &items) // we detect http directory items by its display name and its stripped link // if same, we consider it as a valid item. - if (strLinkTemp != ".." && strLinkTemp != "" && NameMatchesLink(strNameTemp, strLinkTemp)) + if (strLinkTemp != ".." && !strLinkTemp.empty() && NameMatchesLink(strNameTemp, strLinkTemp)) { CFileItemPtr pItem(new CFileItem(strNameTemp)); pItem->SetProperty("IsHTTPDirectory", true); @@ -244,10 +244,10 @@ bool CHTTPDirectory::GetDirectory(const CURL& url, CFileItemList &items) minute = reDateTime.GetMatch(5); } - if (month.length() > 0) + if (!month.empty()) monthNum = CDateTime::MonthStringToMonthNum(month); - if (day.length() > 0 && monthNum > 0 && year.length() > 0) + if (!day.empty() && monthNum > 0 && !year.empty()) { pItem->m_dateTime = CDateTime(atoi(year.c_str()), monthNum, atoi(day.c_str()), atoi(hour.c_str()), atoi(minute.c_str()), 0); } diff --git a/xbmc/filesystem/IDirectory.cpp b/xbmc/filesystem/IDirectory.cpp index b2ad59ab739..b0e71237dd4 100644 --- a/xbmc/filesystem/IDirectory.cpp +++ b/xbmc/filesystem/IDirectory.cpp @@ -103,7 +103,7 @@ void IDirectory::SetMask(const std::string& strMask) m_strFileMask = strMask; // ensure it's completed with a | so that filtering is easy. StringUtils::ToLower(m_strFileMask); - if (m_strFileMask.size() && m_strFileMask[m_strFileMask.size() - 1] != '|') + if (!m_strFileMask.empty() && m_strFileMask[m_strFileMask.size() - 1] != '|') m_strFileMask += '|'; } diff --git a/xbmc/filesystem/VideoDatabaseFile.cpp b/xbmc/filesystem/VideoDatabaseFile.cpp index 0eb28169360..5845c287aa5 100644 --- a/xbmc/filesystem/VideoDatabaseFile.cpp +++ b/xbmc/filesystem/VideoDatabaseFile.cpp @@ -55,7 +55,7 @@ VideoDbContentType CVideoDatabaseFile::GetType(const CURL& url) return VideoDbContentType::UNKNOWN; std::vector pathElem = StringUtils::Split(strPath, "/"); - if (pathElem.size() == 0) + if (pathElem.empty()) return VideoDbContentType::UNKNOWN; const std::string& itemType = pathElem.at(2); diff --git a/xbmc/filesystem/VirtualDirectory.cpp b/xbmc/filesystem/VirtualDirectory.cpp index 5b28f574403..1cc94b1b377 100644 --- a/xbmc/filesystem/VirtualDirectory.cpp +++ b/xbmc/filesystem/VirtualDirectory.cpp @@ -190,7 +190,7 @@ void CVirtualDirectory::GetSources(std::vector& shares) const { share.strStatus = CServiceBroker::GetMediaManager().GetDiskLabel(share.strPath); share.strDiskUniqueId = CServiceBroker::GetMediaManager().GetDiskUniqueId(share.strPath); - if (!share.strPath.length()) // unmounted CD + if (share.strPath.empty()) // unmounted CD { if (CServiceBroker::GetMediaManager().GetDiscPath() == "iso9660://") share.strPath = "iso9660://"; diff --git a/xbmc/filesystem/ZipDirectory.cpp b/xbmc/filesystem/ZipDirectory.cpp index cd29d907f8c..52d2cd8f9da 100644 --- a/xbmc/filesystem/ZipDirectory.cpp +++ b/xbmc/filesystem/ZipDirectory.cpp @@ -65,7 +65,7 @@ namespace XFILE { std::vector items; g_ZipManager.GetZipList(url, items); - if (items.size()) + if (!items.empty()) { if (items.size() > 1) return true; diff --git a/xbmc/guilib/GUIAction.cpp b/xbmc/guilib/GUIAction.cpp index c5040dd3ff4..65f59217b1d 100644 --- a/xbmc/guilib/GUIAction.cpp +++ b/xbmc/guilib/GUIAction.cpp @@ -136,7 +136,7 @@ bool CGUIAction::HasActionsMeetingCondition() const bool CGUIAction::HasAnyActions() const { - return m_actions.size() > 0; + return !m_actions.empty(); } size_t CGUIAction::GetActionCount() const diff --git a/xbmc/guilib/GUIBaseContainer.cpp b/xbmc/guilib/GUIBaseContainer.cpp index 70c7a1a2bd9..a1a3954b45e 100644 --- a/xbmc/guilib/GUIBaseContainer.cpp +++ b/xbmc/guilib/GUIBaseContainer.cpp @@ -173,7 +173,7 @@ void CGUIBaseContainer::Process(unsigned int currentTime, CDirtyRegionList &dirt end += cacheAfter * m_layout->Size(m_orientation); int current = offset - cacheBefore; - while (pos < end && m_items.size()) + while (pos < end && !m_items.empty()) { int itemNo = CorrectOffset(current, 0); if (itemNo >= (int)m_items.size()) @@ -288,7 +288,7 @@ void CGUIBaseContainer::Render() int current = offset - cacheBefore; std::vector renderitems; - while (pos < end && m_items.size()) + while (pos < end && !m_items.empty()) { int itemNo = CorrectOffset(current, 0); if (itemNo >= (int)m_items.size()) @@ -467,7 +467,7 @@ bool CGUIBaseContainer::OnAction(const CAction &action) return true; case ACTION_LAST_PAGE: - if (m_items.size()) + if (!m_items.empty()) SelectItem(m_items.size() - 1); return true; @@ -644,7 +644,7 @@ void CGUIBaseContainer::OnNextLetter() void CGUIBaseContainer::OnPrevLetter() { int offset = CorrectOffset(GetOffset(), GetCursor()); - if (!m_letterOffsets.size()) + if (m_letterOffsets.empty()) return; for (int i = (int)m_letterOffsets.size() - 1; i >= 0; i--) { @@ -666,7 +666,7 @@ void CGUIBaseContainer::OnJumpLetter(const std::string& letter, bool skip /*=fal m_matchTimer.StartZero(); // we can't jump through letters if we have none - if (0 == m_letterOffsets.size()) + if (m_letterOffsets.empty()) return; // find the current letter we're focused on @@ -701,7 +701,7 @@ void CGUIBaseContainer::OnJumpSMS(int letter) static const char letterMap[8][6] = { "ABC2", "DEF3", "GHI4", "JKL5", "MNO6", "PQRS7", "TUV8", "WXYZ9" }; // only 2..9 supported - if (letter < 2 || letter > 9 || !m_letterOffsets.size()) + if (letter < 2 || letter > 9 || m_letterOffsets.empty()) return; const std::string letters = letterMap[letter - 2]; @@ -757,7 +757,7 @@ int CGUIBaseContainer::GetSelectedItem() const std::shared_ptr CGUIBaseContainer::GetListItem(int offset, unsigned int flag) const { - if (!m_items.size() || !m_layout) + if (m_items.empty() || !m_layout) return std::shared_ptr(); int item = GetSelectedItem() + offset; if (flag & INFOFLAG_LISTITEM_POSITION) // use offset from the first item displayed, taking into account scrolling @@ -1405,7 +1405,8 @@ bool CGUIBaseContainer::GetCondition(int condition, int data) const case CONTAINER_HAS_PREVIOUS: return (HasPreviousPage()); case CONTAINER_HAS_PARENT_ITEM: - return (m_items.size() && m_items[0]->IsFileItem() && (std::static_pointer_cast(m_items[0]))->IsParentFolder()); + return (!m_items.empty() && m_items[0]->IsFileItem() && + (std::static_pointer_cast(m_items[0]))->IsParentFolder()); case CONTAINER_SUBITEM: { CGUIListItemLayout *layout = GetFocusedLayout(); @@ -1473,7 +1474,8 @@ std::string CGUIBaseContainer::GetLabel(int info) const break; case CONTAINER_CURRENT_ITEM: { - if (m_items.size() && m_items[0]->IsFileItem() && (std::static_pointer_cast(m_items[0]))->IsParentFolder()) + if (!m_items.empty() && m_items[0]->IsFileItem() && + (std::static_pointer_cast(m_items[0]))->IsParentFolder()) label = std::to_string(GetSelectedItem()); else label = std::to_string(GetSelectedItem() + 1); diff --git a/xbmc/guilib/GUIControlFactory.cpp b/xbmc/guilib/GUIControlFactory.cpp index 7e80228329f..2c2320ff4d8 100644 --- a/xbmc/guilib/GUIControlFactory.cpp +++ b/xbmc/guilib/GUIControlFactory.cpp @@ -491,7 +491,7 @@ bool CGUIControlFactory::GetConditionalVisibility(const TiXmlNode* control, conditions.emplace_back(node->FirstChild()->Value()); node = node->NextSiblingElement("visible"); } - if (!conditions.size()) + if (conditions.empty()) return false; if (conditions.size() == 1) condition = conditions[0]; @@ -643,7 +643,7 @@ void CGUIControlFactory::GetInfoLabel(const TiXmlNode* pControlNode, { std::vector labels; GetInfoLabels(pControlNode, labelTag, labels, parentID); - if (labels.size()) + if (!labels.empty()) infoLabel = labels[0]; } @@ -698,7 +698,7 @@ void CGUIControlFactory::GetInfoLabels(const TiXmlNode* pControlNode, if (infoNode) { // nodes override