summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@suse.cz>2013-04-17 18:52:28 +0200
committerLuboš Luňák <l.lunak@suse.cz>2013-04-17 18:57:22 +0200
commitf22006dc6ac34a35a060e15466cf6b2d2058617d (patch)
tree6f23fa01b4249dec65598c0a4adab8fba541bcba /sw
parenta43cc9ec8dde4f311bcf8ff96e6a26d56b2abdcf (diff)
fix stupid over-optimization
There's so little to be gained by storing pointers to simple or refcounted types instead of using an instance. At least SwTxtNode::GetMinMaxSize() and SwTxtNode::GetScalingOfSelectedText() pass string temporaries to SwDrawTextInfo, so keeping a pointer is clearly broken, and MSVC manages to optimize the code enough to crash because of this. As all the pointers point to const references and are accesses using const references as well, there shouldn't be any harm in making a copy. This fixes smoketest crash on Windows. Change-Id: I7d7cb42e175a2e64fe9c84c98c0d0204a0c25c13
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/inc/drawfont.hxx22
-rw-r--r--sw/source/core/txtnode/swfont.cxx10
2 files changed, 15 insertions, 17 deletions
diff --git a/sw/source/core/inc/drawfont.hxx b/sw/source/core/inc/drawfont.hxx
index 204a1a708a29..f4a8b3d61f8b 100644
--- a/sw/source/core/inc/drawfont.hxx
+++ b/sw/source/core/inc/drawfont.hxx
@@ -42,12 +42,12 @@ class SwDrawTextInfo
OutputDevice* pOut;
ViewShell* pSh;
const SwScriptInfo* pScriptInfo;
- const Point* pPos;
- const OUString* pText;
+ Point pPos;
+ OUString pText;
const SwWrongList* pWrong;
const SwWrongList* pGrammarCheck;
const SwWrongList* pSmartTags;
- const Size* pSize;
+ Size pSize;
SwFont *pFnt;
SwUnderlineFont* pUnderFnt;
xub_StrLen* pHyphPos;
@@ -111,7 +111,7 @@ public:
pSh = pS;
pOut = &rO;
pScriptInfo = pSI;
- pText = &rSt;
+ pText = rSt;
nIdx = nI;
nLen = nL;
nKern = 0;
@@ -129,11 +129,9 @@ public:
// These values are initialized but have to be set explicitly via their
// Set-function before they may be accessed by their Get-function:
- pPos = 0;
pWrong = 0;
pGrammarCheck = 0;
pSmartTags = 0;
- pSize = 0;
pFnt = 0;
pHyphPos = 0;
nLeft = 0;
@@ -192,7 +190,7 @@ public:
#ifdef DBG_UTIL
OSL_ENSURE( m_bPos, "DrawTextInfo: Undefined Position" );
#endif
- return *pPos;
+ return pPos;
}
xub_StrLen *GetHyphPos() const
@@ -205,7 +203,7 @@ public:
const OUString &GetText() const
{
- return *pText;
+ return pText;
}
const SwWrongList* GetWrong() const
@@ -234,7 +232,7 @@ public:
#ifdef DBG_UTIL
OSL_ENSURE( m_bSize, "DrawTextInfo: Undefined Size" );
#endif
- return *pSize;
+ return pSize;
}
SwFont* GetFont() const
@@ -402,7 +400,7 @@ public:
void SetPos( const Point &rNew )
{
- pPos = &rNew;
+ pPos = rNew;
#ifdef DBG_UTIL
m_bPos = true;
#endif
@@ -418,7 +416,7 @@ public:
void SetText( const OUString &rNew )
{
- pText = &rNew;
+ pText = rNew;
}
void SetWrong( const SwWrongList* pNew )
@@ -444,7 +442,7 @@ public:
void SetSize( const Size &rNew )
{
- pSize = &rNew;
+ pSize = rNew;
#ifdef DBG_UTIL
m_bSize = true;
#endif
diff --git a/sw/source/core/txtnode/swfont.cxx b/sw/source/core/txtnode/swfont.cxx
index ea9dd55ac081..aed20794146a 100644
--- a/sw/source/core/txtnode/swfont.cxx
+++ b/sw/source/core/txtnode/swfont.cxx
@@ -1163,17 +1163,17 @@ void SwDrawTextInfo::Shift( sal_uInt16 nDir )
switch ( nDir )
{
case 0 :
- ((Point*)pPos)->X() += GetSize().Width();
+ pPos.X() += GetSize().Width();
break;
case 900 :
- OSL_ENSURE( ((Point*)pPos)->Y() >= GetSize().Width(), "Going underground" );
- ((Point*)pPos)->Y() -= GetSize().Width();
+ OSL_ENSURE( pPos.Y() >= GetSize().Width(), "Going underground" );
+ pPos.Y() -= GetSize().Width();
break;
case 1800 :
- ((Point*)pPos)->X() -= GetSize().Width();
+ pPos.X() -= GetSize().Width();
break;
case 2700 :
- ((Point*)pPos)->Y() += GetSize().Width();
+ pPos.Y() += GetSize().Width();
break;
}
}