File tree 1 file changed +5
-12
lines changed
src/main/java/org/xerial/snappy
1 file changed +5
-12
lines changed Original file line number Diff line number Diff line change 16
16
import java .io .InputStream ;
17
17
import java .io .OutputStream ;
18
18
import java .nio .ByteBuffer ;
19
+ import java .nio .ByteOrder ;
19
20
import java .nio .channels .Channels ;
20
21
import java .nio .channels .ClosedChannelException ;
21
22
import java .nio .channels .ReadableByteChannel ;
@@ -669,17 +670,9 @@ private FrameMetaData getFrameMetaData(ByteBuffer frameHeader)
669
670
private FrameData getFrameData (ByteBuffer content )
670
671
throws IOException
671
672
{
672
- return new FrameData (getCrc32c (content ), 4 );
673
- }
674
-
675
- private int getCrc32c (ByteBuffer content )
676
- {
677
-
678
- final int position = content .position ();
679
-
680
- return ((content .get (position + 3 ) & 0xFF ) << 24 )
681
- | ((content .get (position + 2 ) & 0xFF ) << 16 )
682
- | ((content .get (position + 1 ) & 0xFF ) << 8 )
683
- | (content .get (position ) & 0xFF );
673
+ // the first 4 bytes are the crc32c value in little endian order
674
+ content .order (ByteOrder .LITTLE_ENDIAN );
675
+ final int crc32c = content .getInt (content .position ());
676
+ return new FrameData (crc32c , 4 );
684
677
}
685
678
}
You can’t perform that action at this time.
0 commit comments