freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Git][freetype/freetype][master] [sfnt] Use faster macros in checksums.


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype][master] [sfnt] Use faster macros in checksums.
Date: Thu, 02 May 2024 03:28:56 +0000

Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType

Commits:

  • 4d504684
    by Alexei Podtelezhnikov (Алексей Подтележников) at 2024-05-01T23:19:31-04:00
    [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.
    

2 changed files:

Changes:

  • src/sfnt/sfwoff2.c
    ... ... @@ -289,17 +289,15 @@
    289 289
         FT_ULong  checksum     = 0;
    
    290 290
         FT_ULong  aligned_size = size & ~3UL;
    
    291 291
         FT_ULong  i;
    
    292
    +    FT_Int    shift;
    
    292 293
     
    
    293 294
     
    
    294 295
         for ( i = 0; i < aligned_size; i += 4 )
    
    295
    -      checksum += ( (FT_ULong)buf[i    ] << 24 ) |
    
    296
    -                  ( (FT_ULong)buf[i + 1] << 16 ) |
    
    297
    -                  ( (FT_ULong)buf[i + 2] <<  8 ) |
    
    298
    -                  ( (FT_ULong)buf[i + 3] <<  0 );
    
    296
    +      checksum += FT_NEXT_ULONG( buf );
    
    299 297
     
    
    300 298
         /* remaining bytes can be shifted and added one at a time */
    
    301
    -    for ( ; i < size; ++i )
    
    302
    -      checksum += (FT_ULong)buf[i] << ( 24 - 8 * ( i & 3 ) );
    
    299
    +    for ( shift = 24; i < size; i++, shift -= 8 )
    
    300
    +      checksum += (FT_UInt32)FT_NEXT_BYTE( buf ) << shift;
    
    303 301
     
    
    304 302
         return checksum;
    
    305 303
       }
    

  • src/truetype/ttobjs.c
    ... ... @@ -256,17 +256,20 @@
    256 256
       {
    
    257 257
         FT_Error   error;
    
    258 258
         FT_UInt32  checksum = 0;
    
    259
    -    FT_UInt    i;
    
    259
    +    FT_Byte*   p;
    
    260
    +    FT_Int     shift;
    
    260 261
     
    
    261 262
     
    
    262 263
         if ( FT_FRAME_ENTER( length ) )
    
    263 264
           return 0;
    
    264 265
     
    
    266
    +    p = (FT_Byte*)stream->cursor;
    
    267
    +
    
    265 268
         for ( ; length > 3; length -= 4 )
    
    266
    -      checksum += (FT_UInt32)FT_GET_ULONG();
    
    269
    +      checksum += FT_NEXT_ULONG( p );
    
    267 270
     
    
    268
    -    for ( i = 3; length > 0; length--, i-- )
    
    269
    -      checksum += (FT_UInt32)FT_GET_BYTE() << ( i * 8 );
    
    271
    +    for ( shift = 24; length > 0; length--, shift -=8 )
    
    272
    +      checksum += (FT_UInt32)FT_NEXT_BYTE( p ) << shift;
    
    270 273
     
    
    271 274
         FT_FRAME_EXIT();
    
    272 275
     
    


  • reply via email to

    [Prev in Thread] Current Thread [Next in Thread]