[Libreoffice-commits] core.git: sw/source
Matthew J. Francis
mjay.francis at gmail.com
Fri Oct 3 00:30:24 PDT 2014
sw/source/core/text/itratr.cxx | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
New commits:
commit 7f5ed8228290e6e9ca9fac301d6a6adbda31ff23
Author: Matthew J. Francis <mjay.francis at gmail.com>
Date: Fri Oct 3 11:27:20 2014 +0800
Speed up SwAttrIter::GetNextAttr()
The inner loop which iterates over the characters of
m_pTxtNode->GetTxt() is already bounded to the length of the
string, so there's no need to pay the price of checking its length
for each array position
Change-Id: I7674ea2b46db75fea30dd016b96ec932068fd73b
Reviewed-on: https://gerrit.libreoffice.org/11784
Reviewed-by: David Tardon <dtardon at redhat.com>
Tested-by: David Tardon <dtardon at redhat.com>
diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx
index 3c4451c..a66618f 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -306,11 +306,19 @@ sal_Int32 SwAttrIter::GetNextAttr( ) const
// TODO maybe use hints like FieldHints for this instead of looking at the text...
const sal_Int32 l = nNext<m_pTxtNode->Len() ? nNext : m_pTxtNode->Len();
sal_Int32 p=nPos;
- while (p<l && m_pTxtNode->GetTxt()[p] != CH_TXT_ATR_FIELDSTART
- && m_pTxtNode->GetTxt()[p] != CH_TXT_ATR_FIELDEND
- && m_pTxtNode->GetTxt()[p] != CH_TXT_ATR_FORMELEMENT)
+ const sal_Unicode* aStr = m_pTxtNode->GetTxt().getStr();
+ while (p<l)
{
- ++p;
+ sal_Unicode aChar = aStr[p];
+ if (aChar < CH_TXT_ATR_FORMELEMENT
+ || aChar > CH_TXT_ATR_FIELDEND)
+ {
+ ++p;
+ }
+ else
+ {
+ break;
+ }
}
if ((p<l && p>nPos) || nNext<=p)
nNext=p;
More information about the Libreoffice-commits
mailing list