Kaydet (Commit) 7f5ed822 authored tarafından Matthew J. Francis's avatar Matthew J. Francis Kaydeden (comit) David Tardon

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/11784Reviewed-by: 's avatarDavid Tardon <dtardon@redhat.com>
Tested-by: 's avatarDavid Tardon <dtardon@redhat.com>
üst 794e5c7a
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment