From 7f5ed8228290e6e9ca9fac301d6a6adbda31ff23 Mon Sep 17 00:00:00 2001 From: "Matthew J. Francis" Date: Fri, 3 Oct 2014 11:27:20 +0800 Subject: 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 Tested-by: David Tardon --- sw/source/core/text/itratr.cxx | 16 ++++++++++++---- 1 file 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 = nNextLen() ? nNext : m_pTxtNode->Len(); sal_Int32 p=nPos; - while (pGetTxt()[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 CH_TXT_ATR_FIELDEND) + { + ++p; + } + else + { + break; + } } if ((pnPos) || nNext<=p) nNext=p; -- cgit