[Libreoffice-commits] core.git: 2 commits - editeng/source oox/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Fri Sep 6 02:13:45 PDT 2013
editeng/source/editeng/impedit2.cxx | 32 ++++++++++++++++++++++++--------
oox/source/drawingml/fillproperties.cxx | 2 +-
2 files changed, 25 insertions(+), 9 deletions(-)
New commits:
commit 871cc47c5ea66d1c2f1cbff5d7564202192ea84c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Sep 6 11:01:46 2013 +0200
use a faster standard algorithm to workaround performance problem, fdo#68089
We have here an O(n^2) algorithm. At least using std::find_if here
improves the inner loop and fixes the problem with the bug document.
Change-Id: I88dea9434df6c669f4897927a721ad1518d7ca5e
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index b9d3103..aa8c3fdb 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -1739,6 +1739,24 @@ void ImpEditEngine::InitScriptTypes( sal_Int32 nPara )
}
}
+namespace {
+
+struct FindByPos
+{
+ FindByPos(sal_uInt16 nPos):
+ mnPos(nPos) {}
+
+ bool operator()(const ScriptTypePosInfos::value_type& rValue)
+ {
+ return rValue.nStartPos <= mnPos && rValue.nEndPos >= mnPos;
+ }
+
+private:
+ sal_uInt16 mnPos;
+};
+
+}
+
sal_uInt16 ImpEditEngine::GetScriptType( const EditPaM& rPaM, sal_uInt16* pEndPos ) const
{
sal_uInt16 nScriptType = 0;
@@ -1754,16 +1772,14 @@ sal_uInt16 ImpEditEngine::GetScriptType( const EditPaM& rPaM, sal_uInt16* pEndPo
((ImpEditEngine*)this)->InitScriptTypes( nPara );
const ScriptTypePosInfos& rTypes = pParaPortion->aScriptInfos;
+
sal_uInt16 nPos = rPaM.GetIndex();
- for ( size_t n = 0; n < rTypes.size(); n++ )
+ ScriptTypePosInfos::const_iterator itr = std::find_if(rTypes.begin(), rTypes.end(), FindByPos(nPos));
+ if(itr != rTypes.end())
{
- if ( ( rTypes[n].nStartPos <= nPos ) && ( rTypes[n].nEndPos >= nPos ) )
- {
- nScriptType = rTypes[n].nScriptType;
- if( pEndPos )
- *pEndPos = rTypes[n].nEndPos;
- break;
- }
+ nScriptType = itr->nScriptType;
+ if( pEndPos )
+ *pEndPos = itr->nEndPos;
}
}
return nScriptType ? nScriptType : GetI18NScriptTypeOfLanguage( GetDefaultLanguage() );
commit 3bc61004287e1d1a734c6046019d605742f6c629
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Sep 5 17:35:01 2013 +0200
CID#1078768: pass big parameter by reference
Change-Id: I423e6e0b3a7c16461765b5086f729cce028c4b6e
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx
index bb2eb57..403b816 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -52,7 +52,7 @@ namespace drawingml {
namespace {
-Reference< XGraphic > lclCheckAndApplyDuotoneTransform( BlipFillProperties aBlipProps, Reference< XGraphic > xGraphic,
+Reference< XGraphic > lclCheckAndApplyDuotoneTransform( const BlipFillProperties& aBlipProps, Reference< XGraphic > xGraphic,
const GraphicHelper& rGraphicHelper, const sal_Int32 nPhClr )
{
if( aBlipProps.maDuotoneColors[0].isUsed() && aBlipProps.maDuotoneColors[1].isUsed() )
More information about the Libreoffice-commits
mailing list