[sfnt] Use faster macros in checksums.
* src/truetype/ttobjs.c (tt_synth_sfnt_checksum): Use FT_NEXT_XXX. * src/sfnt/sfwoff2.c (compute_ULong_sum): Use macros.
This commit is contained in:
parent
13da904267
commit
4d50468478
|
@ -289,17 +289,15 @@
|
|||
FT_ULong checksum = 0;
|
||||
FT_ULong aligned_size = size & ~3UL;
|
||||
FT_ULong i;
|
||||
FT_Int shift;
|
||||
|
||||
|
||||
for ( i = 0; i < aligned_size; i += 4 )
|
||||
checksum += ( (FT_ULong)buf[i ] << 24 ) |
|
||||
( (FT_ULong)buf[i + 1] << 16 ) |
|
||||
( (FT_ULong)buf[i + 2] << 8 ) |
|
||||
( (FT_ULong)buf[i + 3] << 0 );
|
||||
checksum += FT_NEXT_ULONG( buf );
|
||||
|
||||
/* remaining bytes can be shifted and added one at a time */
|
||||
for ( ; i < size; ++i )
|
||||
checksum += (FT_ULong)buf[i] << ( 24 - 8 * ( i & 3 ) );
|
||||
for ( shift = 24; i < size; i++, shift -= 8 )
|
||||
checksum += (FT_UInt32)FT_NEXT_BYTE( buf ) << shift;
|
||||
|
||||
return checksum;
|
||||
}
|
||||
|
|
|
@ -256,17 +256,20 @@
|
|||
{
|
||||
FT_Error error;
|
||||
FT_UInt32 checksum = 0;
|
||||
FT_UInt i;
|
||||
FT_Byte* p;
|
||||
FT_Int shift;
|
||||
|
||||
|
||||
if ( FT_FRAME_ENTER( length ) )
|
||||
return 0;
|
||||
|
||||
for ( ; length > 3; length -= 4 )
|
||||
checksum += (FT_UInt32)FT_GET_ULONG();
|
||||
p = (FT_Byte*)stream->cursor;
|
||||
|
||||
for ( i = 3; length > 0; length--, i-- )
|
||||
checksum += (FT_UInt32)FT_GET_BYTE() << ( i * 8 );
|
||||
for ( ; length > 3; length -= 4 )
|
||||
checksum += FT_NEXT_ULONG( p );
|
||||
|
||||
for ( shift = 24; length > 0; length--, shift -=8 )
|
||||
checksum += (FT_UInt32)FT_NEXT_BYTE( p ) << shift;
|
||||
|
||||
FT_FRAME_EXIT();
|
||||
|
||||
|
|
Loading…
Reference in New Issue