File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -387,8 +387,12 @@ pub(crate) fn apply_color_indexing_transform(
387
387
table_data : & [ u8 ] ,
388
388
) {
389
389
if table_size > 16 {
390
- // convert the table of colors into a Vec of color values that can be directly indexed, and that the compiler knows are always 4 bytes in size
391
- let mut table: Vec < [ u8 ; 4 ] > = table_data. chunks_exact ( 4 ) . map ( |c| TryInto :: < [ u8 ; 4 ] > :: try_into ( c) . unwrap ( ) ) . collect ( ) ;
390
+ // convert the table of colors into a Vec of color values that can be directly indexed
391
+ let mut table: Vec < [ u8 ; 4 ] > = table_data
392
+ . chunks_exact ( 4 )
393
+ // convince the compiler that each chunk is 4 bytes long, important for optimizations in the loop below
394
+ . map ( |c| TryInto :: < [ u8 ; 4 ] > :: try_into ( c) . unwrap ( ) )
395
+ . collect ( ) ;
392
396
// pad the table to 256 values if it's smaller than that so we could index into it by u8 without bounds checks
393
397
table. resize ( 256 , [ 0 ; 4 ] ) ;
394
398
// convince the compiler that the length of the table is 256 to avoid bounds checks in the loop below
You can’t perform that action at this time.
0 commit comments