[Libreoffice-commits] core.git: desktop/source

Julien Nabet serval2412 at yahoo.fr
Fri Nov 3 06:14:06 UTC 2017


 desktop/source/deployment/registry/component/dp_compbackenddb.hxx     |    4 -
 desktop/source/deployment/registry/component/dp_component.cxx         |   38 ++++------
 desktop/source/deployment/registry/configuration/dp_configuration.cxx |   13 +--
 desktop/source/deployment/registry/dp_backenddb.cxx                   |   18 ++--
 desktop/source/deployment/registry/inc/dp_backenddb.hxx               |    6 -
 5 files changed, 36 insertions(+), 43 deletions(-)

New commits:
commit 42bfbc216474b4f60d5a5e52a88d95baded5191c
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Thu Nov 2 20:32:43 2017 +0100

    Replace remaining lists by deques (desktop)
    
    because of addToUnoRc and addToConfigmgrIni which use push_front
    (and no easy way to change this), I couldn't use vectors
    
    + use for range loops
    
    Change-Id: I15300122b449b3a5af7c6402a7ad4cd5a2000413
    Reviewed-on: https://gerrit.libreoffice.org/44233
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>

diff --git a/desktop/source/deployment/registry/component/dp_compbackenddb.hxx b/desktop/source/deployment/registry/component/dp_compbackenddb.hxx
index 02d03e1b206f..56f9579f0003 100644
--- a/desktop/source/deployment/registry/component/dp_compbackenddb.hxx
+++ b/desktop/source/deployment/registry/component/dp_compbackenddb.hxx
@@ -23,7 +23,7 @@
 #include <rtl/ustring.hxx>
 #include <rtl/string.hxx>
 #include <vector>
-#include <list>
+#include <deque>
 #include <dp_backenddb.hxx>
 
 namespace com { namespace sun { namespace star {
@@ -75,7 +75,7 @@ public:
     {
         Data(): javaTypeLibrary(false) {};
 
-        std::list< OUString> implementationNames;
+        std::deque< OUString> implementationNames;
         std::vector< std::pair< OUString, OUString> >singletons;
             // map from singleton names to implementation names
         bool javaTypeLibrary;
diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx
index fca9e143d075..a41c68d1de5e 100644
--- a/desktop/source/deployment/registry/component/dp_component.cxx
+++ b/desktop/source/deployment/registry/component/dp_component.cxx
@@ -47,7 +47,7 @@
 #include <com/sun/star/ucb/NameClash.hpp>
 #include <com/sun/star/util/theMacroExpander.hpp>
 #include <algorithm>
-#include <list>
+#include <deque>
 #include <memory>
 #include <unordered_map>
 #include <vector>
@@ -63,7 +63,7 @@ namespace backend {
 namespace component {
 namespace {
 
-typedef std::list<OUString> t_stringlist;
+typedef std::deque<OUString> t_stringlist;
 typedef std::vector< std::pair<OUString, OUString> > t_stringpairvec;
 
 #define IMPLEMENTATION_NAME  "com.sun.star.comp.deployment.component.PackageRegistryBackend"
@@ -942,15 +942,14 @@ void BackendImpl::unorc_flush( Reference<XCommandEnvironment> const & xCmdEnv )
                 xCmdEnv, m_xComponentContext );
             ucb_content.writeStream( xData, true /* replace existing */ );
         }
-        for (t_stringlist::iterator i(m_components.begin());
-             i != m_components.end(); ++i)
+        for (auto const& component : m_components)
         {
             if (space)
             {
                 buf.append(' ');
             }
             buf.append('?');
-            buf.append(OUStringToOString(*i, RTL_TEXTENCODING_UTF8));
+            buf.append(OUStringToOString(component, RTL_TEXTENCODING_UTF8));
             space = true;
         }
         buf.append(LF);
@@ -992,7 +991,8 @@ void BackendImpl::removeFromUnoRc(
     const OUString rcterm( dp_misc::makeRcTerm(url_) );
     const ::osl::MutexGuard guard( getMutex() );
     unorc_verify_init( xCmdEnv );
-    getRcItemList(kind).remove( rcterm );
+    t_stringlist aRcItemList = getRcItemList(kind);
+    aRcItemList.erase(std::remove(aRcItemList.begin(), aRcItemList.end(), rcterm), aRcItemList.end());
     // write immediately:
     m_unorc_modified = true;
     unorc_flush( xCmdEnv );
@@ -1192,35 +1192,33 @@ void BackendImpl::ComponentPackageImpl::componentLiveInsertion(
         rootContext->getServiceManager(), css::uno::UNO_QUERY_THROW);
     std::vector< css::uno::Reference< css::uno::XInterface > >::const_iterator
         factory(factories.begin());
-    for (t_stringlist::const_iterator i(data.implementationNames.begin());
-         i != data.implementationNames.end(); ++i)
+    for (auto const& implementationName : data.implementationNames)
     {
         try {
             set->insert(css::uno::Any(*factory++));
         } catch (const container::ElementExistException &) {
-            SAL_WARN("desktop.deployment", "implementation already registered " << *i);
+            SAL_WARN("desktop.deployment", "implementation already registered " << implementationName);
         }
     }
     if (!data.singletons.empty()) {
         css::uno::Reference< css::container::XNameContainer > cont(
             rootContext, css::uno::UNO_QUERY_THROW);
-        for (t_stringpairvec::const_iterator i(data.singletons.begin());
-             i != data.singletons.end(); ++i)
+        for (auto const& singleton : data.singletons)
         {
-            OUString name("/singletons/" + i->first);
+            OUString name("/singletons/" + singleton.first);
             //TODO: Update should be atomic:
             try {
                 cont->removeByName( name + "/arguments");
             } catch (const container::NoSuchElementException &) {}
             try {
-                cont->insertByName( name + "/service", css::uno::Any(i->second));
+                cont->insertByName( name + "/service", css::uno::Any(singleton.second));
             } catch (const container::ElementExistException &) {
-                cont->replaceByName( name + "/service", css::uno::Any(i->second));
+                cont->replaceByName( name + "/service", css::uno::Any(singleton.second));
             }
             try {
                 cont->insertByName(name, css::uno::Any());
             } catch (const container::ElementExistException &) {
-                SAL_WARN("desktop.deployment", "singleton already registered " << i->first);
+                SAL_WARN("desktop.deployment", "singleton already registered " << singleton.first);
                 cont->replaceByName(name, css::uno::Any());
             }
         }
@@ -1234,11 +1232,10 @@ void BackendImpl::ComponentPackageImpl::componentLiveRemoval(
         getMyBackend()->getRootContext());
     css::uno::Reference< css::container::XSet > set(
         rootContext->getServiceManager(), css::uno::UNO_QUERY_THROW);
-    for (t_stringlist::const_iterator i(data.implementationNames.begin());
-         i != data.implementationNames.end(); ++i)
+    for (auto const& implementationName : data.implementationNames)
     {
         try {
-            set->remove(css::uno::Any(*i));
+            set->remove(css::uno::Any(implementationName));
         } catch (const css::container::NoSuchElementException &) {
             // ignore if factory has not been live deployed
         }
@@ -1246,10 +1243,9 @@ void BackendImpl::ComponentPackageImpl::componentLiveRemoval(
     if (!data.singletons.empty()) {
         css::uno::Reference< css::container::XNameContainer > cont(
             rootContext, css::uno::UNO_QUERY_THROW);
-        for (t_stringpairvec::const_iterator i(data.singletons.begin());
-             i != data.singletons.end(); ++i)
+        for (auto const& singleton : data.singletons)
         {
-            OUString name("/singletons/" + i->first);
+            OUString name("/singletons/" + singleton.first);
             //TODO: Removal should be atomic:
             try {
                 cont->removeByName(name);
diff --git a/desktop/source/deployment/registry/configuration/dp_configuration.cxx b/desktop/source/deployment/registry/configuration/dp_configuration.cxx
index a7807d9515e6..5739d3f444c0 100644
--- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx
+++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx
@@ -45,7 +45,7 @@
 #include <com/sun/star/lang/IllegalArgumentException.hpp>
 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
 #include <com/sun/star/util/XRefreshable.hpp>
-#include <list>
+#include <deque>
 #include <memory>
 #include <utility>
 
@@ -61,7 +61,7 @@ namespace backend {
 namespace configuration {
 namespace {
 
-typedef std::list<OUString> t_stringlist;
+typedef std::deque<OUString> t_stringlist;
 
 
 class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
@@ -737,8 +737,7 @@ void BackendImpl::PackageImpl::processPackage_(
             // Obsolete package database handling - should be removed for LibreOffice 4.0
             t_string2string_map entries(
                 that->m_registeredPackages->getEntries());
-            for (t_string2string_map::iterator i(entries.begin());
-                 i != entries.end(); ++i)
+            for (auto const& entry : entries)
             {
                 //If the xcu file was installed before the configmgr was changed
                 //to use the configmgr.ini, one needed to rebuild to whole directory
@@ -746,9 +745,9 @@ void BackendImpl::PackageImpl::processPackage_(
                 //we just add all other xcu/xcs files to the configmgr.ini instead of
                 //rebuilding the directory structure.
                 OUString url2(
-                    OStringToOUString(i->first, RTL_TEXTENCODING_UTF8));
+                    OStringToOUString(entry.first, RTL_TEXTENCODING_UTF8));
                 if (url2 != url) {
-                   bool schema = i->second.equalsIgnoreAsciiCase(
+                   bool schema = entry.second.equalsIgnoreAsciiCase(
                        "vnd.sun.star.configuration-schema");
                    OUString url_replaced(url2);
                    ConfigurationBackendDb::Data data;
@@ -767,7 +766,7 @@ void BackendImpl::PackageImpl::processPackage_(
                    data.iniEntry = dp_misc::makeRcTerm(url_replaced);
                    that->addDataToDb(url2, data);
                 }
-                that->m_registeredPackages->erase(i->first);
+                that->m_registeredPackages->erase(entry.first);
             }
             try
             {
diff --git a/desktop/source/deployment/registry/dp_backenddb.cxx b/desktop/source/deployment/registry/dp_backenddb.cxx
index f7054869a45e..85003e0bb7da 100644
--- a/desktop/source/deployment/registry/dp_backenddb.cxx
+++ b/desktop/source/deployment/registry/dp_backenddb.cxx
@@ -288,8 +288,7 @@ void BackendDb::writeVectorOfPair(
         xParent->appendChild(
             Reference<css::xml::dom::XNode>(
                 vectorNode, css::uno::UNO_QUERY_THROW));
-        typedef std::vector< std::pair< OUString, OUString > >::const_iterator CIT;
-        for (CIT i = vecPairs.begin(); i != vecPairs.end(); ++i)
+        for (auto const& vecPair : vecPairs)
         {
             const Reference<css::xml::dom::XElement> pairNode(
                 doc->createElementNS(sNameSpace, sPrefix + sPairTagName));
@@ -306,7 +305,7 @@ void BackendDb::writeVectorOfPair(
                     firstNode, css::uno::UNO_QUERY_THROW));
 
             const Reference<css::xml::dom::XText> firstTextNode(
-                doc->createTextNode( i->first));
+                doc->createTextNode( vecPair.first));
 
             firstNode->appendChild(
                 Reference<css::xml::dom::XNode>(
@@ -320,7 +319,7 @@ void BackendDb::writeVectorOfPair(
                     secondNode, css::uno::UNO_QUERY_THROW));
 
             const Reference<css::xml::dom::XText> secondTextNode(
-                doc->createTextNode( i->second));
+                doc->createTextNode( vecPair.second));
 
             secondNode->appendChild(
                 Reference<css::xml::dom::XNode>(
@@ -384,7 +383,7 @@ BackendDb::readVectorOfPair(
 
 //Only writes the data if there is at least one entry
 void BackendDb::writeSimpleList(
-    std::list< OUString> const & list,
+    std::deque< OUString> const & list,
     OUString const & sListTagName,
     OUString const & sMemberTagName,
     Reference<css::xml::dom::XNode> const & xParent)
@@ -404,8 +403,7 @@ void BackendDb::writeSimpleList(
             Reference<css::xml::dom::XNode>(
                 listNode, css::uno::UNO_QUERY_THROW));
 
-        typedef std::list<OUString>::const_iterator ITC_ITEMS;
-        for (ITC_ITEMS i = list.begin(); i != list.end(); ++i)
+        for (auto const& elem : list)
         {
             const Reference<css::xml::dom::XNode> memberNode(
                 doc->createElementNS(sNameSpace, sPrefix + sMemberTagName), css::uno::UNO_QUERY_THROW);
@@ -413,7 +411,7 @@ void BackendDb::writeSimpleList(
             listNode->appendChild(memberNode);
 
             const Reference<css::xml::dom::XNode> textNode(
-                doc->createTextNode( *i), css::uno::UNO_QUERY_THROW);
+                doc->createTextNode(elem), css::uno::UNO_QUERY_THROW);
 
             memberNode->appendChild(textNode);
         }
@@ -532,7 +530,7 @@ OUString BackendDb::readSimpleElement(
 }
 
 
-std::list< OUString> BackendDb::readList(
+std::deque< OUString> BackendDb::readList(
     Reference<css::xml::dom::XNode> const & parent,
     OUString const & sListTagName,
     OUString const & sMemberTagName)
@@ -547,7 +545,7 @@ std::list< OUString> BackendDb::readList(
         const Reference<css::xml::dom::XNodeList> list =
             xpathApi->selectNodeList(parent, sExprList);
 
-        std::list<OUString > retList;
+        std::deque<OUString > retList;
         sal_Int32 length = list->getLength();
         for (sal_Int32 i = 0; i < length; i++)
         {
diff --git a/desktop/source/deployment/registry/inc/dp_backenddb.hxx b/desktop/source/deployment/registry/inc/dp_backenddb.hxx
index 8e619d091020..53ee5e56569d 100644
--- a/desktop/source/deployment/registry/inc/dp_backenddb.hxx
+++ b/desktop/source/deployment/registry/inc/dp_backenddb.hxx
@@ -21,7 +21,7 @@
 #define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_REGISTRY_INC_DP_BACKENDDB_HXX
 
 #include <rtl/ustring.hxx>
-#include <list>
+#include <deque>
 #include <vector>
 
 namespace com { namespace sun { namespace star {
@@ -70,7 +70,7 @@ protected:
         OUString const & url);
 
     void writeSimpleList(
-        std::list< OUString> const & list,
+        std::deque< OUString> const & list,
         OUString const & sListTagName,
         OUString const & sMemberTagName,
         css::uno::Reference<css::xml::dom::XNode> const & xParent);
@@ -102,7 +102,7 @@ protected:
         OUString const & sFirstTagName,
         OUString const & sSecondTagName);
 
-    std::list< OUString> readList(
+    std::deque< OUString> readList(
         css::uno::Reference<css::xml::dom::XNode> const & parent,
         OUString const & sListTagName,
         OUString const & sMemberTagName);


More information about the Libreoffice-commits mailing list