Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType
Commits:
-
4d504684
by Alexei Podtelezhnikov (Алексей Подтележников) at 2024-05-01T23:19:31-04:00
2 changed files:
Changes:
... | ... | @@ -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 | }
|
... | ... | @@ -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 |