[Libreoffice-commits] core.git: include/vcl vcl/unx

Julien Nabet serval2412 at yahoo.fr
Sat Oct 21 16:09:12 UTC 2017


 include/vcl/ppdparser.hxx             |    7 +++----
 vcl/unx/generic/printer/cpdmgr.cxx    |   18 +++++++++---------
 vcl/unx/generic/printer/ppdparser.cxx |   18 +++++++++---------
 3 files changed, 21 insertions(+), 22 deletions(-)

New commits:
commit ea6858c1e388c2d17a0825f3d21353ded67083eb
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Sat Oct 21 08:58:01 2017 +0200

    Replace lists by vectors in ppdparser (vcl)
    
    + simplify some parts
    
    Change-Id: I78c611f234e06e542be56016231f6c16d44e4385
    Reviewed-on: https://gerrit.libreoffice.org/43640
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/vcl/ppdparser.hxx b/include/vcl/ppdparser.hxx
index d01852117b0a..227c617961d2 100644
--- a/include/vcl/ppdparser.hxx
+++ b/include/vcl/ppdparser.hxx
@@ -19,7 +19,6 @@
 #ifndef INCLUDED_VCL_PPDPARSER_HXX
 #define INCLUDED_VCL_PPDPARSER_HXX
 
-#include <list>
 #include <unordered_map>
 #include <vector>
 
@@ -141,7 +140,7 @@ public:
 private:
     hash_type                                   m_aKeys;
     value_type                                  m_aOrderedKeys;
-    ::std::list< PPDConstraint >                m_aConstraints;
+    ::std::vector< PPDConstraint >              m_aConstraints;
 
     // some identifying fields
     OUString                                    m_aPrinterName;
@@ -181,7 +180,7 @@ private:
     void parseOrderDependency(const OString& rLine);
     void parseOpenUI(const OString& rLine, const OString& rPPDGroup);
     void parseConstraint(const OString& rLine);
-    void parse( std::list< OString >& rLines );
+    void parse( std::vector< OString >& rLines );
 
     OUString handleTranslation(const OString& i_rString, bool i_bIsGlobalized);
 
@@ -197,7 +196,7 @@ public:
     int             getKeys() const { return m_aKeys.size(); }
     bool            hasKey( const PPDKey* ) const;
 
-    const ::std::list< PPDConstraint >& getConstraints() const { return m_aConstraints; }
+    const ::std::vector< PPDConstraint >& getConstraints() const { return m_aConstraints; }
 
     bool            isColorDevice() const { return m_bColorDevice; }
     bool            isType42Capable() const { return m_bType42Capable; }
diff --git a/vcl/unx/generic/printer/cpdmgr.cxx b/vcl/unx/generic/printer/cpdmgr.cxx
index eb5c079e4625..7c932a410bba 100644
--- a/vcl/unx/generic/printer/cpdmgr.cxx
+++ b/vcl/unx/generic/printer/cpdmgr.cxx
@@ -517,21 +517,21 @@ void CPDManager::initialize()
 
     // remove everything that is not a CUPS printer and not
     // a special purpose printer (PDF, Fax)
-    std::list< OUString > aRemovePrinters;
-    for( std::unordered_map< OUString, Printer, OUStringHash >::iterator it = m_aPrinters.begin();
-         it != m_aPrinters.end(); ++it )
+    std::unordered_map< OUString, Printer, OUStringHash >::iterator it = m_aPrinters.begin();
+    while (it != m_aPrinters.end())
     {
         if( m_aCPDDestMap.find( it->first ) != m_aCPDDestMap.end() )
+        {
+            ++it;
             continue;
+        }
 
         if( !it->second.m_aInfo.m_aFeatures.isEmpty() )
+        {
+            ++it;
             continue;
-        aRemovePrinters.push_back( it->first );
-    }
-    while( aRemovePrinters.begin() != aRemovePrinters.end() )
-    {
-        m_aPrinters.erase( aRemovePrinters.front() );
-        aRemovePrinters.pop_front();
+        }
+        it = m_aPrinters.erase(it);
     }
 #endif
 }
diff --git a/vcl/unx/generic/printer/ppdparser.cxx b/vcl/unx/generic/printer/ppdparser.cxx
index 3c7e3555cdb8..6c9afb9d109e 100644
--- a/vcl/unx/generic/printer/ppdparser.cxx
+++ b/vcl/unx/generic/printer/ppdparser.cxx
@@ -239,7 +239,7 @@ namespace psp
     class PPDCache
     {
     public:
-        std::list< std::unique_ptr<PPDParser> > aAllParsers;
+        std::vector< std::unique_ptr<PPDParser> > aAllParsers;
         std::unique_ptr<std::unordered_map< OUString, OUString, OUStringHash >> pAllPPDFiles;
         PPDCache()
             : pAllPPDFiles(nullptr)
@@ -583,8 +583,8 @@ const PPDParser* PPDParser::getParser( const OUString& rFile )
                     rPPDCache.aAllParsers.end(),
                     [pNewParser] (std::unique_ptr<PPDParser> const & x) { return x.get() == pNewParser; } ),
                 rPPDCache.aAllParsers.end());
-        // insert new parser to list
-        rPPDCache.aAllParsers.push_front( std::unique_ptr<PPDParser>(pNewParser) );
+        // insert new parser to vector
+        rPPDCache.aAllParsers.emplace_back( std::unique_ptr<PPDParser>(pNewParser) );
     }
     return pNewParser;
 }
@@ -721,7 +721,7 @@ PPDParser::PPDParser( const OUString& rFile ) :
         m_pTranslator( new PPDTranslator() )
 {
     // read in the file
-    std::list< OString > aLines;
+    std::vector< OString > aLines;
     PPDDecompressStream aStream( m_aFile );
     if( aStream.IsOpen() )
     {
@@ -815,7 +815,7 @@ PPDParser::PPDParser( const OUString& rFile ) :
     }
     SAL_INFO("vcl.unx.print",
             "constraints: (" << m_aConstraints.size() << " found)");
-    for( std::list< PPDConstraint >::const_iterator cit = m_aConstraints.begin(); cit != m_aConstraints.end(); ++cit )
+    for( std::vector< PPDConstraint >::const_iterator cit = m_aConstraints.begin(); cit != m_aConstraints.end(); ++cit )
     {
         SAL_INFO("vcl.unx.print", "*\"" << cit->m_pKey1->getKey() << "\" \""
                 << (cit->m_pOption1 ? cit->m_pOption1->m_aOption : "<nil>")
@@ -962,7 +962,7 @@ namespace
     }
 }
 
-void PPDParser::parse( ::std::list< OString >& rLines )
+void PPDParser::parse( ::std::vector< OString >& rLines )
 {
     // Name for PPD group into which all options are put for which the PPD
     // does not explicitly define a group.
@@ -974,7 +974,7 @@ void PPDParser::parse( ::std::list< OString >& rLines )
     // "Extra" group depending on the option.
     static const OString aDefaultPPDGroupName("General");
 
-    std::list< OString >::iterator line = rLines.begin();
+    std::vector< OString >::iterator line = rLines.begin();
     PPDParser::hash_type::const_iterator keyit;
 
     // name of the PPD group that is currently being processed
@@ -1814,8 +1814,8 @@ bool PPDContext::checkConstraints( const PPDKey* pKey, const PPDValue* pNewValue
         pNewValue == pKey->getDefaultValue() )
         return true;
 
-    const ::std::list< PPDParser::PPDConstraint >& rConstraints( m_pParser->getConstraints() );
-    for( ::std::list< PPDParser::PPDConstraint >::const_iterator it = rConstraints.begin(); it != rConstraints.end(); ++it )
+    const ::std::vector< PPDParser::PPDConstraint >& rConstraints( m_pParser->getConstraints() );
+    for( ::std::vector< PPDParser::PPDConstraint >::const_iterator it = rConstraints.begin(); it != rConstraints.end(); ++it )
     {
         const PPDKey* pLeft     = it->m_pKey1;
         const PPDKey* pRight    = it->m_pKey2;


More information about the Libreoffice-commits mailing list