[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - 3 commits - sw/inc sw/source writerfilter/source

Michael Meeks michael.meeks at collabora.com
Tue Jun 24 00:46:56 PDT 2014


 sw/inc/pagedesc.hxx                                   |    1 +
 sw/source/core/doc/docdesc.cxx                        |    2 +-
 sw/source/core/unocore/unostyle.cxx                   |   18 +++++++++---------
 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx |    6 +++---
 writerfilter/source/ooxml/OOXMLFastContextHandler.hxx |    2 +-
 5 files changed, 15 insertions(+), 14 deletions(-)

New commits:
commit 7d32ac663e7ac4c6f3f22d003c3f36437be43399
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Jun 20 13:50:32 2014 +0100

    fdo#76260 - Switch from vector to std::stack.
    
    std::stack uses std::deque which is extremely expensive for this case.
    This change saves 43bn of 98bn cycles spent in createFastChildContext.
    
    Change-Id: I63919a9826563171f128e09d7206ac6cfdde336f
    (cherry picked from commit 295b97b2a654e00ac5a8e6a3545284fa583fce78)
    Signed-off-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index 1a436ce..7fd973c 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -181,7 +181,7 @@ bool OOXMLFastContextHandler::prepareMceContext(Token_t nElement, const uno::Ref
                 m_bDiscardChildren = false;
                 aState.m_bTookChoice = m_bTookChoice;
                 m_bTookChoice = false;
-                m_aSavedAlternateStates.push(aState);
+                m_aSavedAlternateStates.push_back(aState);
             }
             break;
         case OOXML_Choice:
@@ -268,8 +268,8 @@ throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
         m_bDiscardChildren = false;
     else if (Element == (NS_mce | OOXML_AlternateContent))
     {
-        SavedAlternateState aState(m_aSavedAlternateStates.top());
-        m_aSavedAlternateStates.pop();
+        SavedAlternateState aState(m_aSavedAlternateStates.back());
+        m_aSavedAlternateStates.pop_back();
         m_bDiscardChildren = aState.m_bDiscardChildren;
         m_bTookChoice = aState.m_bTookChoice;
     }
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
index f8f2638..a7d9bfa 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
@@ -300,7 +300,7 @@ private:
     uno::Reference< uno::XComponentContext > m_xContext;
     bool m_bDiscardChildren;
     bool m_bTookChoice; ///< Did we take the Choice or want Fallback instead?
-    std::stack<SavedAlternateState> m_aSavedAlternateStates;
+    std::vector<SavedAlternateState> m_aSavedAlternateStates;
 
     static sal_uInt32 mnInstanceCount;
 
commit 22c818bd9fa79a2c008719cc0a858ba2a74b0d82
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Thu Jun 19 22:34:55 2014 +0100

    fdo#76260 - a better approach for getting element names.
    
    Don't do lots more work than we need to to build the list of names.
    It appears that the [] operator does a lot of apparently un-necessary
    work.
    
    (cherry picked from commit 9e5e9dd1b276043d2e9f45c01d72b2e89d8abdf2)
    Signed-off-by: Miklos Vajna <vmiklos at collabora.co.uk>
    
    Conflicts:
    	sw/source/core/unocore/unostyle.cxx
    
    Change-Id: Id603fb4e717dc7130468465493edccfe51d384c7

diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 15a4639..ae28998 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -69,6 +69,7 @@
 
 #include <comphelper/servicehelper.hxx>
 #include <cppuhelper/supportsservice.hxx>
+#include <comphelper/sequenceasvector.hxx>
 
 //UUUU
 #include <unobrushitemhelper.hxx>
@@ -787,23 +788,22 @@ uno::Any SwXStyleFamily::getByName(const OUString& rName)
 uno::Sequence< OUString > SwXStyleFamily::getElementNames(void) throw( uno::RuntimeException, std::exception )
 {
     SolarMutexGuard aGuard;
-    uno::Sequence< OUString > aRet;
+    comphelper::SequenceAsVector< OUString > aRet;
     if(pBasePool)
     {
-        SfxStyleSheetIteratorPtr pIterator = pBasePool->CreateIterator(eFamily, SFXSTYLEBIT_ALL);
-        sal_uInt16 nCount = pIterator->Count();
-        aRet.realloc(nCount);
-        OUString* pArray = aRet.getArray();
+        SfxStyleSheetIteratorPtr pIt = pBasePool->CreateIterator(eFamily, SFXSTYLEBIT_ALL);
         OUString aString;
-        for(sal_uInt16 i = 0; i < nCount; i++)
+        for (SfxStyleSheetBase* pStyle = pIt->First(); pStyle; pStyle = pIt->Next())
         {
-            SwStyleNameMapper::FillProgName((*pIterator)[i]->GetName(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), true );
-            pArray[i] = aString;
+            SwStyleNameMapper::FillProgName(pStyle->GetName(), aString,
+                                            lcl_GetSwEnumFromSfxEnum ( eFamily ), true);
+            aRet.push_back(aString);
         }
     }
     else
         throw uno::RuntimeException();
-    return aRet;
+
+    return aRet.getAsConstList();
 }
 
 sal_Bool SwXStyleFamily::hasByName(const OUString& rName) throw( uno::RuntimeException, std::exception )
commit 51fb76a0beacee9d8a43abca493af1b8d2652b53
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Wed Jun 18 12:56:29 2014 +0100

    fdo#76260 - the wrong way to get a 10% win with an N^3 operation.
    
    Micro optimising the inner-loop is never the right way; on the other
    hand this is 10% of load time and is waste.
    
    (cherry picked from commit 78378af1d404baf78f42930a29dbf8eae22bbe80)
    Signed-off-by: Miklos Vajna <vmiklos at collabora.co.uk>
    
    Change-Id: Ie275be53e30834cbb6576b8e7580c16d2e47bf16

diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx
index a15a851..58ab7a8 100644
--- a/sw/inc/pagedesc.hxx
+++ b/sw/inc/pagedesc.hxx
@@ -162,6 +162,7 @@ protected:
 
 public:
     OUString GetName() const { return aDescName; }
+    bool HasName( const OUString& rThisName ) { return aDescName == rThisName; }
     void SetName( const OUString& rNewName ) { aDescName = rNewName; }
 
     bool GetLandscape() const { return bLandscape; }
diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx
index 062fba3..bb8dd2d 100644
--- a/sw/source/core/doc/docdesc.cxx
+++ b/sw/source/core/doc/docdesc.cxx
@@ -638,7 +638,7 @@ SwPageDesc* SwDoc::FindPageDescByName( const OUString& rName, sal_uInt16* pPos )
     if( pPos ) *pPos = USHRT_MAX;
 
     for( sal_uInt16 n = 0, nEnd = maPageDescs.size(); n < nEnd; ++n )
-        if( maPageDescs[ n ]->GetName() == rName )
+        if( maPageDescs[ n ]->HasName( rName ) )
         {
             pRet = maPageDescs[ n ];
             if( pPos )


More information about the Libreoffice-commits mailing list