Commit 23f85c8a981e1af9f36a838055865d8e7a0fb787

Alexei Podtelezhnikov 2021-04-22T23:34:08

[cache] Optimize SBit copying. * src/cache/ftcsbits.c (ftc_snode_load): Do not initialize the buffer. (ftc_sbit_copy_bitmap): Accept zero size, s/FT_ALLOC/FT_QALLOC/.

diff --git a/ChangeLog b/ChangeLog
index 599b9c3..2cf4c53 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2021-04-22  Alexei Podtelezhnikov  <apodtele@gmail.com>
 
+	[cache] Optimize SBit copying.
+
+	* src/cache/ftcsbits.c (ftc_snode_load): Do not initialize the buffer.
+	(ftc_sbit_copy_bitmap): Accept zero size, s/FT_ALLOC/FT_QALLOC/.
+
+2021-04-22  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
 	[gxvalid,otvalid] s/FT_ALLOC/FT_QALLOC/ for initialized buffers.
 
 	* src/gxvalid/gxvmod.c (gxv_load_table): Do not zero out the buffer.
diff --git a/src/cache/ftcsbits.c b/src/cache/ftcsbits.c
index 33c4538..723192f 100644
--- a/src/cache/ftcsbits.c
+++ b/src/cache/ftcsbits.c
@@ -52,10 +52,8 @@
       pitch = -pitch;
 
     size = (FT_ULong)pitch * bitmap->rows;
-    if ( !size )
-      return FT_Err_Ok;
 
-    if ( !FT_ALLOC( sbit->buffer, size ) )
+    if ( !FT_QALLOC( sbit->buffer, size ) )
       FT_MEM_COPY( sbit->buffer, bitmap->buffer, size );
 
     return error;
@@ -122,8 +120,6 @@
     sbit  = snode->sbits + ( gindex - gnode->gindex );
     clazz = (FTC_SFamilyClass)family->clazz;
 
-    sbit->buffer = NULL;
-
     error = clazz->family_load_glyph( family, gindex, manager, &face );
     if ( error )
       goto BadGlyph;