summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2009-01-29 09:19:20 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2009-01-29 09:19:20 +0000
commitbbf310133a92f157899a2e00adecf5adee63b7ee (patch)
tree06730d1785fc01dfcc33f1bbf7cc3ea0e4bca9fc
parente1f0b385a8f62694b5dbbe856808b5aa10d384b3 (diff)
downloadpango-bbf310133a92f157899a2e00adecf5adee63b7ee.tar.gz
Allocate all array rows in a single ALLOC call. Saves over 2000 alloc
2009-01-29 Behdad Esfahbod <behdad@gnome.org> * pango/opentype/harfbuzz-gpos.c (Load_BaseArray), (Free_BaseArray): Allocate all array rows in a single ALLOC call. Saves over 2000 alloc calls when loading DejaVu Sans! svn path=/trunk/; revision=2815
-rw-r--r--ChangeLog6
-rw-r--r--pango/opentype/harfbuzz-gpos.c57
2 files changed, 23 insertions, 40 deletions
diff --git a/ChangeLog b/ChangeLog
index f5103f66..65ac058e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-01-29 Behdad Esfahbod <behdad@gnome.org>
+
+ * pango/opentype/harfbuzz-gpos.c (Load_BaseArray), (Free_BaseArray):
+ Allocate all array rows in a single ALLOC call. Saves over 2000
+ alloc calls when loading DejaVu Sans!
+
2009-01-28 Behdad Esfahbod <behdad@gnome.org>
Bug 560792 – Make PangoLayoutLine with line->layout==NULL renderable
diff --git a/pango/opentype/harfbuzz-gpos.c b/pango/opentype/harfbuzz-gpos.c
index 02cbd202..6583dee4 100644
--- a/pango/opentype/harfbuzz-gpos.c
+++ b/pango/opentype/harfbuzz-gpos.c
@@ -2000,11 +2000,11 @@ static HB_Error Load_BaseArray( HB_BaseArray* ba,
{
HB_Error error;
- HB_UShort m, n, k, count;
+ HB_UShort m, n, count;
HB_UInt cur_offset, new_offset, base_offset;
- HB_BaseRecord* br;
- HB_Anchor* ban;
+ HB_BaseRecord *br;
+ HB_Anchor *ban, *bans;
base_offset = FILE_Pos();
@@ -2023,19 +2023,21 @@ static HB_Error Load_BaseArray( HB_BaseArray* ba,
br = ba->BaseRecord;
+ bans = NULL;
+
+ if ( ALLOC_ARRAY( bans, count * num_classes, HB_Anchor ) )
+ goto Fail;
+
for ( m = 0; m < count; m++ )
{
br[m].BaseAnchor = NULL;
- if ( ALLOC_ARRAY( br[m].BaseAnchor, num_classes, HB_Anchor ) )
- goto Fail;
-
- ban = br[m].BaseAnchor;
+ ban = br[m].BaseAnchor = bans + m * num_classes;
for ( n = 0; n < num_classes; n++ )
{
if ( ACCESS_Frame( 2L ) )
- goto Fail0;
+ goto Fail;
new_offset = GET_UShort() + base_offset;
@@ -2053,30 +2055,15 @@ static HB_Error Load_BaseArray( HB_BaseArray* ba,
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = Load_Anchor( &ban[n], stream ) ) != HB_Err_Ok )
- goto Fail0;
+ goto Fail;
(void)FILE_Seek( cur_offset );
}
-
- continue;
- Fail0:
- for ( k = 0; k < n; k++ )
- Free_Anchor( &ban[k] );
- goto Fail;
}
return HB_Err_Ok;
Fail:
- for ( k = 0; k < m; k++ )
- {
- ban = br[k].BaseAnchor;
-
- for ( n = 0; n < num_classes; n++ )
- Free_Anchor( &ban[n] );
-
- FREE( ban );
- }
-
+ FREE( bans );
FREE( br );
return error;
}
@@ -2085,27 +2072,17 @@ Fail:
static void Free_BaseArray( HB_BaseArray* ba,
HB_UShort num_classes )
{
- HB_UShort m, n, count;
-
- HB_BaseRecord* br;
- HB_Anchor* ban;
+ HB_BaseRecord *br;
+ HB_Anchor *bans;
+ HB_UNUSED(num_classes);
if ( ba->BaseRecord )
{
- count = ba->BaseCount;
br = ba->BaseRecord;
+ bans = br[0].BaseAnchor;
- for ( m = 0; m < count; m++ )
- {
- ban = br[m].BaseAnchor;
-
- for ( n = 0; n < num_classes; n++ )
- Free_Anchor( &ban[n] );
-
- FREE( ban );
- }
-
+ FREE( bans );
FREE( br );
}
}