xmloff/source/style/xmlexppr.cxx |   21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

New commits:
commit 77f6990b5b990d7e9b247a36f0ed8cb72d00cd69
Author:     Jochen Nitschke <j.nitschke+loger...@ok.de>
AuthorDate: Tue Dec 29 12:43:40 2020 +0100
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Dec 31 08:48:10 2020 +0100

    remove unnecessary list member counter
    
    std::list::size() has constant complexity since C++11
    
    Change-Id: I97c4b0a2d4fe899bcdf5fd2492fed69ed26c20e8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108342
    Tested-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/xmloff/source/style/xmlexppr.cxx b/xmloff/source/style/xmlexppr.cxx
index 893e0fb36ee4..a9cc2962155e 100644
--- a/xmloff/source/style/xmlexppr.cxx
+++ b/xmloff/source/style/xmlexppr.cxx
@@ -156,7 +156,6 @@ typedef std::list<FilterPropertyInfo_Impl> 
FilterPropertyInfoList_Impl;
 
 class FilterPropertiesInfo_Impl
 {
-    sal_uInt32                              nCount;
     FilterPropertyInfoList_Impl             aPropInfos;
 
     std::unique_ptr<Sequence<OUString>>     pApiNames;
@@ -171,11 +170,10 @@ public:
             const Reference< XPropertySet >& xPropSet,
             const rtl::Reference< XMLPropertySetMapper >& maPropMapper,
             const bool bDefault);
-    sal_uInt32 GetPropertyCount() const { return nCount; }
+    sal_uInt32 GetPropertyCount() const { return aPropInfos.size(); }
 };
 
 FilterPropertiesInfo_Impl::FilterPropertiesInfo_Impl() :
-    nCount(0),
     aPropInfos()
 {
 }
@@ -184,7 +182,6 @@ void FilterPropertiesInfo_Impl::AddProperty(
         const OUString& rApiName, const sal_uInt32 nIndex)
 {
     aPropInfos.emplace_back(rApiName, nIndex);
-    nCount++;
 
     OSL_ENSURE( !pApiNames, "performance warning: API names already retrieved" 
);
     pApiNames.reset();
@@ -192,7 +189,6 @@ void FilterPropertiesInfo_Impl::AddProperty(
 
 const uno::Sequence<OUString>& FilterPropertiesInfo_Impl::GetApiNames()
 {
-    OSL_ENSURE(nCount == aPropInfos.size(), "wrong property count");
     if( !pApiNames )
     {
         // we have to do three things:
@@ -204,7 +200,7 @@ const uno::Sequence<OUString>& 
FilterPropertiesInfo_Impl::GetApiNames()
         aPropInfos.sort();
 
         // merge duplicates
-        if ( nCount > 1 )
+        if ( aPropInfos.size() > 1 )
         {
             FilterPropertyInfoList_Impl::iterator aOld = aPropInfos.begin();
             FilterPropertyInfoList_Impl::iterator aEnd = aPropInfos.end();
@@ -225,7 +221,6 @@ const uno::Sequence<OUString>& 
FilterPropertiesInfo_Impl::GetApiNames()
                     aCurrent->GetIndexes().clear();
                     // erase element, and continue with next
                     aCurrent = aPropInfos.erase( aCurrent );
-                    nCount--;
                 }
                 else
                 {
@@ -237,7 +232,7 @@ const uno::Sequence<OUString>& 
FilterPropertiesInfo_Impl::GetApiNames()
         }
 
         // construct sequence
-        pApiNames.reset( new Sequence < OUString >( nCount ) );
+        pApiNames.reset( new Sequence < OUString >( aPropInfos.size() ) );
         OUString *pNames = pApiNames->getArray();
 
         for (auto const& propInfo : aPropInfos)
@@ -273,7 +268,7 @@ void FilterPropertiesInfo_Impl::FillPropertyStateArray(
                 FilterPropertyInfoList_Impl::iterator 
aPropIter(aPropInfos.begin());
                 XMLPropertyState aNewProperty( -1 );
                 sal_uInt32 i = 0;
-                while (nResultCount > 0 && i < nCount)
+                while (nResultCount > 0 && i < aPropInfos.size())
                 {
                     if (pResults->Name == aPropIter->GetApiName())
                     {
@@ -299,7 +294,7 @@ void FilterPropertiesInfo_Impl::FillPropertyStateArray(
             OSL_ENSURE( rApiNames.getLength() == aResults.getLength(), "wrong 
implemented XTolerantMultiPropertySet" );
             FilterPropertyInfoList_Impl::iterator 
aPropIter(aPropInfos.begin());
             XMLPropertyState aNewProperty( -1 );
-            OSL_ENSURE( nCount == 
static_cast<sal_uInt32>(aResults.getLength()), "wrong implemented 
XTolerantMultiPropertySet??" );
+            OSL_ENSURE( aPropInfos.size() == 
static_cast<sal_uInt32>(aResults.getLength()), "wrong implemented 
XTolerantMultiPropertySet??" );
             for( const auto& rResult : aResults )
             {
                 if ((rResult.Result == 
beans::TolerantPropertySetResultType::SUCCESS) &&
@@ -339,7 +334,7 @@ void FilterPropertiesInfo_Impl::FillPropertyStateArray(
                 sal_uInt32 nValueCount = 0;
                 sal_uInt32 i;
 
-                for( i = 0; i < nCount; ++i, ++pStates )
+                for( i = 0; i < aPropInfos.size(); ++i, ++pStates )
                 {
                     if( *pStates == PropertyState_DIRECT_VALUE )
                         nValueCount++;
@@ -400,7 +395,7 @@ void FilterPropertiesInfo_Impl::FillPropertyStateArray(
                 const Any *pValues = aValues.getConstArray();
 
                 FilterPropertyInfoList_Impl::iterator aItr = 
aPropInfos.begin();
-                for(sal_uInt32 i = 0; i < nCount; ++i)
+                for(sal_uInt32 i = 0; i < aPropInfos.size(); ++i)
                 {
                     // The value is stored in the PropertySet itself, add to 
list.
                     XMLPropertyState aNewProperty( -1 );
@@ -418,7 +413,7 @@ void FilterPropertiesInfo_Impl::FillPropertyStateArray(
         else
         {
             FilterPropertyInfoList_Impl::iterator aItr = aPropInfos.begin();
-            for(sal_uInt32 i = 0; i < nCount; ++i)
+            for(sal_uInt32 i = 0; i < aPropInfos.size(); ++i)
             {
                 bool bDirectValue =
                     !pStates || *pStates == PropertyState_DIRECT_VALUE;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to