diff options
author | Matthew J. Francis <mjay.francis@gmail.com> | 2014-10-03 11:27:20 +0800 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2014-10-03 07:30:02 +0000 |
commit | 7f5ed8228290e6e9ca9fac301d6a6adbda31ff23 (patch) | |
tree | 51f59f2a61aaca8e89be8f8e914664f2a013795b /sw | |
parent | 794e5c7a3f4292ac849ca993c12c7953b5e85102 (diff) |
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@redhat.com>
Tested-by: David Tardon <dtardon@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/text/itratr.cxx | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx index 3c4451c162a6..a66618f9076f 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; |