From 7da92fdcb040d1f82fc2a6c61fd05f76f7344035 Mon Sep 17 00:00:00 2001 From: Julien Nabet Date: Sun, 4 Jan 2015 19:09:27 +0100 Subject: cppcheck: Possible inefficient checking for emptiness Change-Id: I6ca0e477a4429e762c48c721951b9876db3a5c6c --- filter/source/config/cache/filtercache.cxx | 12 ++++++------ package/source/xstor/ohierarchyholder.cxx | 2 +- sc/source/filter/excel/excimp8.cxx | 2 +- scripting/source/provider/ProviderCache.cxx | 2 +- scripting/source/stringresource/stringresource.cxx | 2 +- scripting/source/vbaevents/eventhelper.cxx | 2 +- sw/source/core/unocore/unocoll.cxx | 2 +- sw/source/ui/vba/vbadocumentproperties.cxx | 2 +- toolkit/source/controls/dialogcontrol.cxx | 2 +- unotools/source/config/cmdoptions.cxx | 2 +- vcl/source/gdi/pdfwriter_impl.cxx | 2 +- 11 files changed, 16 insertions(+), 16 deletions(-) diff --git a/filter/source/config/cache/filtercache.cxx b/filter/source/config/cache/filtercache.cxx index a1c37c5bc996..69d60277c231 100644 --- a/filter/source/config/cache/filtercache.cxx +++ b/filter/source/config/cache/filtercache.cxx @@ -172,13 +172,13 @@ void FilterCache::takeOver(const FilterCache& rClone) // c4) clone_2 take over unchanged filters(!) and changed types(!) // c5) c4 overwrites c3! - if (rClone.m_lChangedTypes.size()>0) + if (!rClone.m_lChangedTypes.empty()) m_lTypes = rClone.m_lTypes; - if (rClone.m_lChangedFilters.size()>0) + if (!rClone.m_lChangedFilters.empty()) m_lFilters = rClone.m_lFilters; - if (rClone.m_lChangedFrameLoaders.size()>0) + if (!rClone.m_lChangedFrameLoaders.empty()) m_lFrameLoaders = rClone.m_lFrameLoaders; - if (rClone.m_lChangedContentHandlers.size()>0) + if (!rClone.m_lChangedContentHandlers.empty()) m_lContentHandlers = rClone.m_lContentHandlers; m_lChangedTypes.clear(); @@ -1009,11 +1009,11 @@ void FilterCache::impl_validateAndOptimize() if ( ( (bSomeTypesShouldExist) && - (m_lTypes.size() < 1 ) + (m_lTypes.empty()) ) || ( (bAllFiltersShouldExist) && - (m_lFilters.size() < 1 ) + (m_lFilters.empty()) ) ) { diff --git a/package/source/xstor/ohierarchyholder.cxx b/package/source/xstor/ohierarchyholder.cxx index 24784371d5ca..fd2b39f02159 100644 --- a/package/source/xstor/ohierarchyholder.cxx +++ b/package/source/xstor/ohierarchyholder.cxx @@ -235,7 +235,7 @@ void OHierarchyElement_Impl::TestForClosing() { ::osl::MutexGuard aGuard( m_aMutex ); - if ( !m_aOpenStreams.size() && !m_aChildren.size() ) + if ( m_aOpenStreams.empty() && m_aChildren.empty() ) { if ( m_rParent.is() ) { diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx index c1d342ee38dc..ae83bca1e22b 100644 --- a/sc/source/filter/excel/excimp8.cxx +++ b/sc/source/filter/excel/excimp8.cxx @@ -126,7 +126,7 @@ public: virtual sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE { ::osl::MutexGuard aGuard( m_aMutex ); - return ( IdToOleNameHash.size() > 0 ); + return ( !IdToOleNameHash.empty() ); } // XNameAcess virtual uno::Any SAL_CALL getByName( const OUString& aName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE diff --git a/scripting/source/provider/ProviderCache.cxx b/scripting/source/provider/ProviderCache.cxx index b094e2e224de..d02550e3ea87 100644 --- a/scripting/source/provider/ProviderCache.cxx +++ b/scripting/source/provider/ProviderCache.cxx @@ -93,7 +93,7 @@ ProviderCache::getAllProviders() throw ( RuntimeException ) ProviderDetails_hash::iterator h_itEnd = m_hProviderDetailsCache.end(); ProviderDetails_hash::iterator h_it = m_hProviderDetailsCache.begin(); // should assert if size !> 0 - if ( m_hProviderDetailsCache.size() ) + if ( !m_hProviderDetailsCache.empty() ) { sal_Int32 providerIndex = 0; sal_Int32 index = 0; diff --git a/scripting/source/stringresource/stringresource.cxx b/scripting/source/stringresource/stringresource.cxx index 667a9008d2b6..3a693d2297cc 100644 --- a/scripting/source/stringresource/stringresource.cxx +++ b/scripting/source/stringresource/stringresource.cxx @@ -2202,7 +2202,7 @@ bool StringResourcePersistenceImpl::implWritePropertiesFile( LocaleItem* pLocale xTextOutputStream->writeString( aLineFeedStr ); const IdToStringMap& rHashMap = pLocaleItem->m_aIdToStringMap; - if( rHashMap.size() > 0 ) + if( !rHashMap.empty() ) { // Sort ids according to read order const IdToIndexMap& rIndexMap = pLocaleItem->m_aIdToIndexMap; diff --git a/scripting/source/vbaevents/eventhelper.cxx b/scripting/source/vbaevents/eventhelper.cxx index 5ab80dfab21f..a9e970dc964d 100644 --- a/scripting/source/vbaevents/eventhelper.cxx +++ b/scripting/source/vbaevents/eventhelper.cxx @@ -495,7 +495,7 @@ public: virtual Type SAL_CALL getElementType( ) throw (RuntimeException, std::exception) SAL_OVERRIDE { return cppu::UnoType::get(); } virtual sal_Bool SAL_CALL hasElements( ) throw (RuntimeException, std::exception) SAL_OVERRIDE - { return ( ( m_hEvents.size() > 0 ? sal_True : sal_False ) ); } + { return ( ( m_hEvents.empty() ? sal_False : sal_True ) ); } private: typedef std::unordered_map< OUString, Any, OUStringHash, diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index d4fe261d74d4..2a0f65c1b15f 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -234,7 +234,7 @@ public: virtual sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE { - return ( mTemplateToProject.size() > 0 ); + return ( !mTemplateToProject.empty() ); } }; diff --git a/sw/source/ui/vba/vbadocumentproperties.cxx b/sw/source/ui/vba/vbadocumentproperties.cxx index 701ea4d1ac12..2a904386782b 100644 --- a/sw/source/ui/vba/vbadocumentproperties.cxx +++ b/sw/source/ui/vba/vbadocumentproperties.cxx @@ -727,7 +727,7 @@ protected: } virtual sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE { - return mDocProps.size() > 0; + return !mDocProps.empty(); } virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE { diff --git a/toolkit/source/controls/dialogcontrol.cxx b/toolkit/source/controls/dialogcontrol.cxx index 5d84922ac517..af8f6d55a28d 100644 --- a/toolkit/source/controls/dialogcontrol.cxx +++ b/toolkit/source/controls/dialogcontrol.cxx @@ -140,7 +140,7 @@ public: virtual sal_Bool SAL_CALL hasElements( ) throw (RuntimeException, std::exception) SAL_OVERRIDE { ::osl::MutexGuard aGuard( m_aMutex ); - return ( things.size() > 0 ); + return ( !things.empty() ); } }; diff --git a/unotools/source/config/cmdoptions.cxx b/unotools/source/config/cmdoptions.cxx index d343e9ffa347..59b7f1966f4b 100644 --- a/unotools/source/config/cmdoptions.cxx +++ b/unotools/source/config/cmdoptions.cxx @@ -61,7 +61,7 @@ class SvtCmdOptions bool HasEntries() const { - return ( m_aCommandHashMap.size() > 0 ); + return ( !m_aCommandHashMap.empty() ); } bool Lookup( const OUString& aCmd ) const diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 01931775d2dc..5e1f8c2c9aaf 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -5187,7 +5187,7 @@ bool PDFWriterImpl::emitAppearances( PDFWidget& rWidget, OStringBuffer& rAnnotDi break; } - if( rWidget.m_aAppearances.size() ) + if( !rWidget.m_aAppearances.empty() ) { rAnnotDict.append( "/AP<<\n" ); for( PDFAppearanceMap::iterator dict_it = rWidget.m_aAppearances.begin(); dict_it != rWidget.m_aAppearances.end(); ++dict_it ) -- cgit