[Libreoffice-commits] core.git: connectivity/source include/connectivity

Stephan Bergmann sbergman at redhat.com
Thu Jan 5 13:25:09 UTC 2017


 connectivity/source/commontools/filtermanager.cxx |   22 +++++++++++-----------
 include/connectivity/filtermanager.hxx            |    2 +-
 2 files changed, 12 insertions(+), 12 deletions(-)

New commits:
commit 21033d04fd55470cb8b693bca4af2058da2a8dcc
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Jan 5 14:24:28 2017 +0100

    Clean up a usage of OUStringBuffer
    
    Change-Id: I8435865f1a67a3a6d889c1b8a3d30e632ffc61fd

diff --git a/connectivity/source/commontools/filtermanager.cxx b/connectivity/source/commontools/filtermanager.cxx
index 63fe39c..ba2d2df 100644
--- a/connectivity/source/commontools/filtermanager.cxx
+++ b/connectivity/source/commontools/filtermanager.cxx
@@ -120,7 +120,7 @@ namespace dbtools
     }
 
 
-    bool FilterManager::isThereAtMostOneComponent( OUStringBuffer& o_singleComponent ) const
+    bool FilterManager::isThereAtMostOneComponent( OUString& o_singleComponent ) const
     {
         if (m_bApplyPublicFilter) {
             if (!m_aPublicFilterComponent.isEmpty() && !m_aLinkFilterComponent.isEmpty())
@@ -130,13 +130,13 @@ namespace dbtools
             else if (!m_aLinkFilterComponent.isEmpty())
                 o_singleComponent = m_aLinkFilterComponent;
             else
-                o_singleComponent.setLength(0);
+                o_singleComponent.clear();
             return true;
         }
         else
         {
             if (m_aLinkFilterComponent.isEmpty())
-                o_singleComponent.setLength(0);
+                o_singleComponent.clear();
             else
                 o_singleComponent = m_aLinkFilterComponent;
             return true;
@@ -146,17 +146,17 @@ namespace dbtools
 
     OUString FilterManager::getComposedFilter( ) const
     {
-        OUStringBuffer aComposedFilter;
-
         // if we have only one non-empty component, then there's no need to compose anything
-        if ( !isThereAtMostOneComponent( aComposedFilter ) )
+        OUString singleComponent;
+        if ( isThereAtMostOneComponent( singleComponent ) )
         {
-            // append the single components
-            if (m_bApplyPublicFilter)
-                appendFilterComponent( aComposedFilter, m_aPublicFilterComponent );
-            appendFilterComponent( aComposedFilter, m_aLinkFilterComponent );
+            return singleComponent;
         }
-
+        // append the single components
+        OUStringBuffer aComposedFilter(singleComponent);
+        if (m_bApplyPublicFilter)
+            appendFilterComponent( aComposedFilter, m_aPublicFilterComponent );
+        appendFilterComponent( aComposedFilter, m_aLinkFilterComponent );
         return aComposedFilter.makeStringAndClear();
     }
 
diff --git a/include/connectivity/filtermanager.hxx b/include/connectivity/filtermanager.hxx
index 73e9e87..4999ded 100644
--- a/include/connectivity/filtermanager.hxx
+++ b/include/connectivity/filtermanager.hxx
@@ -97,7 +97,7 @@ namespace dbtools
         static void      appendFilterComponent( OUStringBuffer& io_appendTo, const OUString& i_component );
 
         /// checks whether there is only one (or even no) non-empty filter component
-        bool    isThereAtMostOneComponent( OUStringBuffer& o_singleComponent ) const;
+        bool    isThereAtMostOneComponent( OUString& o_singleComponent ) const;
     };
 
 


More information about the Libreoffice-commits mailing list