summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-05-01 16:06:25 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-05-01 16:27:17 +0100
commitfd4fe85329654883a0bf3304ad0aa8ef0bfde844 (patch)
treea24ba18cb3ef5e29bbbbf64acc36ae2108d28c59
parentRelated: fdo#49208 crazy to create the string *twice* (diff)
downloadcore-fd4fe85329654883a0bf3304ad0aa8ef0bfde844.tar.gz
core-fd4fe85329654883a0bf3304ad0aa8ef0bfde844.zip
Related: fdo#49208 don't copy string if we can reuse the original
Change-Id: I95d82ce168fd1790107316460f6ddbd9f6b32e18
-rw-r--r--sw/inc/breakit.hxx7
-rw-r--r--sw/source/core/bastyp/breakit.cxx6
-rw-r--r--sw/source/core/txtnode/txtedt.cxx2
3 files changed, 10 insertions, 5 deletions
diff --git a/sw/inc/breakit.hxx b/sw/inc/breakit.hxx
index 5fa2bd5c3ac5..031d91cefddd 100644
--- a/sw/inc/breakit.hxx
+++ b/sw/inc/breakit.hxx
@@ -96,7 +96,12 @@ public:
sal_uInt16 GetRealScriptOfText( const rtl::OUString& rTxt, sal_Int32 nPos ) const;
sal_uInt16 GetAllScriptsOfText( const rtl::OUString& rTxt ) const;
- sal_Int32 getGraphemeCount(const rtl::OUString& rStr) const;
+ sal_Int32 getGraphemeCount(const rtl::OUString& rStr,
+ sal_Int32 nStart, sal_Int32 nEnd) const;
+ sal_Int32 getGraphemeCount(const rtl::OUString& rStr) const
+ {
+ return getGraphemeCount(rStr, 0, rStr.getLength());
+ }
};
#define SW_BREAKITER() SwBreakIt::Get()
diff --git a/sw/source/core/bastyp/breakit.cxx b/sw/source/core/bastyp/breakit.cxx
index 313fdcac9cb7..1fbadd80114c 100644
--- a/sw/source/core/bastyp/breakit.cxx
+++ b/sw/source/core/bastyp/breakit.cxx
@@ -165,12 +165,12 @@ sal_uInt16 SwBreakIt::GetAllScriptsOfText( const rtl::OUString& rTxt ) const
return nRet;
}
-sal_Int32 SwBreakIt::getGraphemeCount(const rtl::OUString& rText) const
+sal_Int32 SwBreakIt::getGraphemeCount(const rtl::OUString& rText, sal_Int32 nStart, sal_Int32 nEnd) const
{
sal_Int32 nGraphemeCount = 0;
- sal_Int32 nCurPos = 0;
- while (nCurPos < rText.getLength())
+ sal_Int32 nCurPos = nStart;
+ while (nCurPos < nEnd)
{
sal_Int32 nCount2 = 1;
nCurPos = xBreak->nextCharacters(rText, nCurPos, lang::Locale(),
diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx
index cb5e4724fe8c..ae8fe55799c9 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -1913,7 +1913,7 @@ void SwTxtNode::CountWords( SwDocStat& rStat,
}
}
- nTmpChars = pBreakIt->getGraphemeCount(aExpandText.copy(nExpandBegin, nExpandEnd - nExpandBegin));
+ nTmpChars = pBreakIt->getGraphemeCount(aExpandText, nExpandBegin, nExpandEnd);
nTmpChars -= nNumOfMaskedChars;
// no nTmpCharsExcludingSpaces adjust needed neither for blanked out MaskedChars