[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.2' - 2 commits - sw/inc sw/source
Michael Meeks
michael.meeks at collabora.com
Wed Jun 25 02:21:49 PDT 2014
sw/inc/pagedesc.hxx | 1 +
sw/source/core/doc/docdesc.cxx | 2 +-
sw/source/core/unocore/unostyle.cxx | 18 +++++++++---------
3 files changed, 11 insertions(+), 10 deletions(-)
New commits:
commit cbb5b0e93444bd0b42a22bbef01dd8599c9d4483
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.
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 4963b68..d5589ec 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>
#include <boost/shared_ptr.hpp>
@@ -783,23 +784,22 @@ uno::Any SwXStyleFamily::getByName(const OUString& rName)
uno::Sequence< OUString > SwXStyleFamily::getElementNames(void) throw( uno::RuntimeException )
{
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 )
commit edd98c9428e7ac15e16f28503ae831d895ce2a8c
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.
Change-Id: Ie275be53e30834cbb6576b8e7580c16d2e47bf16
(cherry picked from commit 78378af1d404baf78f42930a29dbf8eae22bbe80)
diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx
index b0bccec..1498336 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; }
sal_Bool GetLandscape() const { return bLandscape; }
diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx
index c84a5d2..a3c0a93 100644
--- a/sw/source/core/doc/docdesc.cxx
+++ b/sw/source/core/doc/docdesc.cxx
@@ -635,7 +635,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