[Libreoffice-commits] core.git: Branch 'private/kohei/xlsx-import-speedup' - 2 commits - i18npool/inc i18npool/source sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Fri Nov 8 15:50:18 CET 2013


 i18npool/inc/characterclassificationImpl.hxx                            |   14 +--
 i18npool/source/characterclassification/characterclassificationImpl.cxx |   10 --
 sc/source/filter/inc/formulabuffer.hxx                                  |   14 ---
 sc/source/filter/oox/formulabuffer.cxx                                  |   36 +++-------
 4 files changed, 16 insertions(+), 58 deletions(-)

New commits:
commit 1092aec96eb2fc9ff4c32e6c9d9417f6a7e6d6af
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Nov 8 09:51:23 2013 -0500

    We don't need to put this in a separate thread.
    
    We can do this on the main thread.
    
    Change-Id: I58a32d9e0ce2599c5822903393a5b698233599df

diff --git a/sc/source/filter/inc/formulabuffer.hxx b/sc/source/filter/inc/formulabuffer.hxx
index 7e881ee..2411466 100644
--- a/sc/source/filter/inc/formulabuffer.hxx
+++ b/sc/source/filter/inc/formulabuffer.hxx
@@ -31,20 +31,6 @@ namespace oox { namespace xls {
 
 class FormulaBuffer : public WorkbookHelper
 {
-    class FinalizeThread : public salhelper::Thread
-    {
-        FormulaBuffer& mrParent;
-        size_t mnThreadCount;
-    public:
-        FinalizeThread( FormulaBuffer& rParent, size_t nThreadCount );
-        virtual ~FinalizeThread();
-
-    protected:
-        virtual void execute();
-    };
-
-    friend class FinalizeThread;
-
 public:
     /**
      * Represents a shared formula definition.
diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx
index f58e9f7..fa8e06a 100644
--- a/sc/source/filter/oox/formulabuffer.cxx
+++ b/sc/source/filter/oox/formulabuffer.cxx
@@ -214,15 +214,16 @@ FormulaBuffer::SheetItem::SheetItem() :
     mpSharedFormulaEntries(NULL),
     mpSharedFormulaIDs(NULL) {}
 
-FormulaBuffer::FinalizeThread::FinalizeThread( FormulaBuffer& rParent, size_t nThreadCount ) :
-    salhelper::Thread("xlsx-import-formula-buffer-finalize-thread"),
-    mrParent(rParent), mnThreadCount(nThreadCount) {}
-
-FormulaBuffer::FinalizeThread::~FinalizeThread() {}
+FormulaBuffer::FormulaBuffer( const WorkbookHelper& rHelper ) : WorkbookHelper( rHelper )
+{
+}
 
-void FormulaBuffer::FinalizeThread::execute()
+void FormulaBuffer::finalizeImport()
 {
-    ScDocumentImport& rDoc = mrParent.getDocImport();
+    ISegmentProgressBarRef xFormulaBar = getProgressBar().createSegment( getProgressBar().getFreeLength() );
+
+    const size_t nThreadCount = 1;
+    ScDocumentImport& rDoc = getDocImport();
     rDoc.getDoc().SetAutoNameCache(new ScAutoNameCache(&rDoc.getDoc()));
     ScExternalRefManager::ApiGuard aExtRefGuard(&rDoc.getDoc());
 
@@ -232,11 +233,11 @@ void FormulaBuffer::FinalizeThread::execute()
     std::vector<SheetItem> aSheetItems;
     aSheetItems.reserve(nTabCount);
     for (SCTAB nTab = 0; nTab < nTabCount; ++nTab)
-        aSheetItems.push_back(mrParent.getSheetItem(nTab));
+        aSheetItems.push_back(getSheetItem(nTab));
 
     typedef rtl::Reference<WorkerThread> WorkerThreadRef;
     std::vector<WorkerThreadRef> aThreads;
-    aThreads.reserve(mnThreadCount);
+    aThreads.reserve(nThreadCount);
 
     std::vector<SheetItem>::iterator it = aSheetItems.begin(), itEnd = aSheetItems.end();
 
@@ -246,7 +247,7 @@ void FormulaBuffer::FinalizeThread::execute()
     // lack.
     while (it != itEnd)
     {
-        for (size_t i = 0; i < mnThreadCount; ++i)
+        for (size_t i = 0; i < nThreadCount; ++i)
         {
             if (it == itEnd)
                 break;
@@ -267,21 +268,6 @@ void FormulaBuffer::FinalizeThread::execute()
     }
 
     rDoc.getDoc().SetAutoNameCache(NULL);
-}
-
-FormulaBuffer::FormulaBuffer( const WorkbookHelper& rHelper ) : WorkbookHelper( rHelper )
-{
-}
-
-void FormulaBuffer::finalizeImport()
-{
-    ISegmentProgressBarRef xFormulaBar = getProgressBar().createSegment( getProgressBar().getFreeLength() );
-
-    rtl::Reference<FinalizeThread> xThreadMgr(new FinalizeThread(*this, 1));
-    xThreadMgr->launch();
-
-    if (xThreadMgr.is())
-        xThreadMgr->join();
 
     xFormulaBar->setPosition( 1.0 );
 }
commit fca7257056fd084f2f63dfbe53293f9527be2535
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Nov 8 09:40:25 2013 -0500

    Revert "Guard CharacterClassificationImpl with mutex."
    
    This reverts commit fc04b55f7f96a4f70f31c145dafd44c1d9276a41.

diff --git a/i18npool/inc/characterclassificationImpl.hxx b/i18npool/inc/characterclassificationImpl.hxx
index 24221d1..e220968 100644
--- a/i18npool/inc/characterclassificationImpl.hxx
+++ b/i18npool/inc/characterclassificationImpl.hxx
@@ -26,8 +26,6 @@
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/uno/XComponentContext.hpp>
 
-#include "osl/mutex.hxx"
-
 namespace com { namespace sun { namespace star { namespace i18n {
 
 class CharacterClassificationImpl : public cppu::WeakImplHelper2
@@ -95,19 +93,17 @@ private:
             aLocale.Variant == rLocale.Variant;
         };
     };
+    std::vector<lookupTableItem*> lookupTable;
+    lookupTableItem *cachedItem;
+
+    com::sun::star::uno::Reference < com::sun::star::uno::XComponentContext > m_xContext;
+    com::sun::star::uno::Reference < XCharacterClassification > xUCI;
 
     com::sun::star::uno::Reference < XCharacterClassification > SAL_CALL
     getLocaleSpecificCharacterClassification(const com::sun::star::lang::Locale& rLocale) throw(com::sun::star::uno::RuntimeException);
     sal_Bool SAL_CALL
     createLocaleSpecificCharacterClassification(const OUString& serviceName, const com::sun::star::lang::Locale& rLocale);
 
-private:
-    std::vector<lookupTableItem*> lookupTable;
-    lookupTableItem *cachedItem;
-
-    com::sun::star::uno::Reference < com::sun::star::uno::XComponentContext > m_xContext;
-    com::sun::star::uno::Reference < XCharacterClassification > xUCI;
-    osl::Mutex maMtx;
 };
 
 } } } }
diff --git a/i18npool/source/characterclassification/characterclassificationImpl.cxx b/i18npool/source/characterclassification/characterclassificationImpl.cxx
index bd3c164..e7fe8e6 100644
--- a/i18npool/source/characterclassification/characterclassificationImpl.cxx
+++ b/i18npool/source/characterclassification/characterclassificationImpl.cxx
@@ -47,7 +47,6 @@ OUString SAL_CALL
 CharacterClassificationImpl::toUpper( const OUString& Text, sal_Int32 nPos,
         sal_Int32 nCount, const Locale& rLocale ) throw(RuntimeException)
 {
-    osl::MutexGuard aGuard(&maMtx);
     return getLocaleSpecificCharacterClassification(rLocale)->toUpper(Text, nPos, nCount, rLocale);
 }
 
@@ -55,7 +54,6 @@ OUString SAL_CALL
 CharacterClassificationImpl::toLower( const OUString& Text, sal_Int32 nPos,
         sal_Int32 nCount, const Locale& rLocale ) throw(RuntimeException)
 {
-    osl::MutexGuard aGuard(&maMtx);
     return getLocaleSpecificCharacterClassification(rLocale)->toLower(Text, nPos, nCount, rLocale);
 }
 
@@ -63,7 +61,6 @@ OUString SAL_CALL
 CharacterClassificationImpl::toTitle( const OUString& Text, sal_Int32 nPos,
         sal_Int32 nCount, const Locale& rLocale ) throw(RuntimeException)
 {
-    osl::MutexGuard aGuard(&maMtx);
     return getLocaleSpecificCharacterClassification(rLocale)->toTitle(Text, nPos, nCount, rLocale);
 }
 
@@ -71,7 +68,6 @@ sal_Int16 SAL_CALL
 CharacterClassificationImpl::getType( const OUString& Text, sal_Int32 nPos )
         throw(RuntimeException)
 {
-    osl::MutexGuard aGuard(&maMtx);
     if (xUCI.is())
         return xUCI->getType(Text, nPos);
     throw RuntimeException();
@@ -81,7 +77,6 @@ sal_Int16 SAL_CALL
 CharacterClassificationImpl::getCharacterDirection( const OUString& Text, sal_Int32 nPos )
         throw(RuntimeException)
 {
-    osl::MutexGuard aGuard(&maMtx);
     if (xUCI.is())
         return xUCI->getCharacterDirection(Text, nPos);
     throw RuntimeException();
@@ -91,7 +86,6 @@ sal_Int16 SAL_CALL
 CharacterClassificationImpl::getScript( const OUString& Text, sal_Int32 nPos )
         throw(RuntimeException)
 {
-    osl::MutexGuard aGuard(&maMtx);
     if (xUCI.is())
         return xUCI->getScript(Text, nPos);
     throw RuntimeException();
@@ -101,7 +95,6 @@ sal_Int32 SAL_CALL
 CharacterClassificationImpl::getCharacterType( const OUString& Text, sal_Int32 nPos,
         const Locale& rLocale ) throw(RuntimeException)
 {
-    osl::MutexGuard aGuard(&maMtx);
     return getLocaleSpecificCharacterClassification(rLocale)->getCharacterType(Text, nPos, rLocale);
 }
 
@@ -109,7 +102,6 @@ sal_Int32 SAL_CALL
 CharacterClassificationImpl::getStringType( const OUString& Text, sal_Int32 nPos,
         sal_Int32 nCount, const Locale& rLocale ) throw(RuntimeException)
 {
-    osl::MutexGuard aGuard(&maMtx);
     return getLocaleSpecificCharacterClassification(rLocale)->getStringType(Text, nPos, nCount, rLocale);
 }
 
@@ -119,7 +111,6 @@ ParseResult SAL_CALL CharacterClassificationImpl::parseAnyToken(
         sal_Int32 contCharTokenType, const OUString& userDefinedCharactersCont )
         throw(RuntimeException)
 {
-    osl::MutexGuard aGuard(&maMtx);
     return getLocaleSpecificCharacterClassification(rLocale)->parseAnyToken(Text, nPos, rLocale,
             startCharTokenType,userDefinedCharactersStart,
             contCharTokenType, userDefinedCharactersCont);
@@ -132,7 +123,6 @@ ParseResult SAL_CALL CharacterClassificationImpl::parsePredefinedToken(
         const OUString& userDefinedCharactersStart, sal_Int32 contCharTokenType,
         const OUString& userDefinedCharactersCont ) throw(RuntimeException)
 {
-    osl::MutexGuard aGuard(&maMtx);
     return getLocaleSpecificCharacterClassification(rLocale)->parsePredefinedToken(
             nTokenType, Text, nPos, rLocale, startCharTokenType, userDefinedCharactersStart,
             contCharTokenType, userDefinedCharactersCont);


More information about the Libreoffice-commits mailing list