File tree Expand file tree Collapse file tree
src/ImageSharp/Formats/Png/Zlib Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -381,14 +381,15 @@ public static short BitReverse(int toReverse)
381381 * fail as expected. We can't simply check whether the value is lower than
382382 * 15 << 12, because higher values are acceptable in the first 3 accesses.
383383 * Doing this reduces the total number of index checks from 4 down to just 1. */
384- Guard . MustBeLessThanOrEqualTo < uint > ( ( uint ) ( toReverse >> 12 ) , 15 , nameof ( toReverse ) ) ;
384+ int toReverseRightShiftBy12 = toReverse >> 12 ;
385+ Guard . MustBeLessThanOrEqualTo < uint > ( ( uint ) toReverseRightShiftBy12 , 15 , nameof ( toReverse ) ) ;
385386
386387 ref byte bit4ReverseRef = ref MemoryMarshal . GetReference ( Bit4Reverse ) ;
387388
388389 return ( short ) ( Unsafe . Add ( ref bit4ReverseRef , toReverse & 0xF ) << 12
389390 | Unsafe . Add ( ref bit4ReverseRef , ( toReverse >> 4 ) & 0xF ) << 8
390391 | Unsafe . Add ( ref bit4ReverseRef , ( toReverse >> 8 ) & 0xF ) << 4
391- | Unsafe . Add ( ref bit4ReverseRef , toReverse >> 12 ) ) ;
392+ | Unsafe . Add ( ref bit4ReverseRef , toReverseRightShiftBy12 ) ) ;
392393 }
393394
394395 /// <inheritdoc/>
You can’t perform that action at this time.
0 commit comments