summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorNorbert Thiebaud <nthiebaud@gmail.com>2012-03-04 19:30:04 -0600
committerNorbert Thiebaud <nthiebaud@gmail.com>2012-03-04 21:12:48 -0600
commit2ea4964b2e81a25125eec7ce3eb0b06b3883edf0 (patch)
tree92bba31d500bbd117ffc50264c90e78539125081 /vcl
parent6bb68cae7c31918eff8386d5b52be0759386bb60 (diff)
help GlyphItems vector to be sized correctly up-front
Diffstat (limited to 'vcl')
-rw-r--r--vcl/generic/glyphs/gcach_layout.cxx4
-rw-r--r--vcl/generic/print/genpspgraphics.cxx3
-rw-r--r--vcl/inc/sallayout.hxx1
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx1
4 files changed, 9 insertions, 0 deletions
diff --git a/vcl/generic/glyphs/gcach_layout.cxx b/vcl/generic/glyphs/gcach_layout.cxx
index 5f92f4855f56..ef03aa302311 100644
--- a/vcl/generic/glyphs/gcach_layout.cxx
+++ b/vcl/generic/glyphs/gcach_layout.cxx
@@ -106,6 +106,8 @@ bool ServerFontLayoutEngine::operator()( ServerFontLayout& rLayout, ImplLayoutAr
int nGlyphWidth = 0;
GlyphItem aPrevItem;
bool bRightToLeft;
+
+ rLayout.Reserve(rArgs.mnLength);
for( int nCharPos = -1; rArgs.GetNextPos( &nCharPos, &bRightToLeft ); )
{
sal_UCS4 cChar = rArgs.mpStr[ nCharPos ];
@@ -409,6 +411,8 @@ bool IcuLayoutEngine::operator()( ServerFontLayout& rLayout, ImplLayoutArgs& rAr
// allocate temporary arrays, note: round to even
int nGlyphCapacity = (3 * (rArgs.mnEndCharPos - rArgs.mnMinCharPos ) | 15) + 1;
+ rLayout.Reserve(nGlyphCapacity);
+
struct IcuPosition{ float fX, fY; };
const int nAllocSize = sizeof(LEGlyphID) + sizeof(le_int32) + sizeof(IcuPosition);
LEGlyphID* pIcuGlyphs = (LEGlyphID*)alloca( (nGlyphCapacity * nAllocSize) + sizeof(IcuPosition) );
diff --git a/vcl/generic/print/genpspgraphics.cxx b/vcl/generic/print/genpspgraphics.cxx
index b806c1d933ba..29c0610c53d1 100644
--- a/vcl/generic/print/genpspgraphics.cxx
+++ b/vcl/generic/print/genpspgraphics.cxx
@@ -616,6 +616,9 @@ bool PspFontLayout::LayoutText( ImplLayoutArgs& rArgs )
Point aNewPos( 0, 0 );
GlyphItem aPrevItem;
rtl_TextEncoding aFontEnc = mrPrinterGfx.GetFontMgr().getFontEncoding( mnFontID );
+
+ Reserve(rArgs.mnLength);
+
for(;;)
{
bool bRightToLeft;
diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx
index a9a30d03f7e8..85c04f0f2fd0 100644
--- a/vcl/inc/sallayout.hxx
+++ b/vcl/inc/sallayout.hxx
@@ -345,6 +345,7 @@ class VCL_PLUGIN_PUBLIC GenericSalLayout : public SalLayout
public:
// used by layout engines
void AppendGlyph( const GlyphItem& );
+ void Reserve(int size) { m_GlyphItems.reserve(size + 1); }
virtual void AdjustLayout( ImplLayoutArgs& );
virtual void ApplyDXArray( ImplLayoutArgs& );
virtual void Justify( long nNewWidth );
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 3820d81eff4a..603104f67335 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -2364,6 +2364,7 @@ bool PDFSalLayout::LayoutText( ImplLayoutArgs& rArgs )
Point aNewPos( 0, 0 );
bool bRightToLeft;
+ Reserve(rArgs.mnLength);
for( int nCharPos = -1; rArgs.GetNextPos( &nCharPos, &bRightToLeft ); )
{
// TODO: handle unicode surrogates