From 43f04e78a33fbe25aaaef7a72f0f1bb5da007955 Mon Sep 17 00:00:00 2001 From: Matteo Casalin Date: Sat, 21 Feb 2015 09:00:16 +0100 Subject: Do not compare OUStrings twice Change-Id: I94f7cecf5b39c1f03b9f10a13b5efa63bb06ced8 --- sw/source/core/doc/docnum.cxx | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index ee294d272918..77dfbc5bfdde 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -570,17 +570,20 @@ static sal_uInt16 lcl_FindOutlineName( const SwNodes& rNds, const OUString& rNam for( SwOutlineNodes::size_type n = 0; n < rOutlNds.size(); ++n ) { SwTxtNode* pTxtNd = rOutlNds[ n ]->GetTxtNode(); - OUString sTxt( pTxtNd->GetExpandTxt() ); - if (sTxt == rName) + const OUString sTxt( pTxtNd->GetExpandTxt() ); + if (sTxt.startsWith(rName)) { - // Found "exact", set Pos to the Node - nSavePos = n; - break; - } - else if( !bExact && USHRT_MAX == nSavePos && sTxt.startsWith(rName) ) - { - // maybe we just found the text's first part - nSavePos = n; + if (sTxt.getLength() == rName.getLength()) + { + // Found "exact", set Pos to the Node + nSavePos = n; + break; + } + else if( !bExact && USHRT_MAX == nSavePos ) + { + // maybe we just found the text's first part + nSavePos = n; + } } } -- cgit