File tree Expand file tree Collapse file tree 1 file changed +5
-12
lines changed
src/main/java/org/xerial/snappy Expand file tree Collapse file tree 1 file changed +5
-12
lines changed Original file line number Diff line number Diff line change 1616import java .io .InputStream ;
1717import java .io .OutputStream ;
1818import java .nio .ByteBuffer ;
19+ import java .nio .ByteOrder ;
1920import java .nio .channels .Channels ;
2021import java .nio .channels .ClosedChannelException ;
2122import java .nio .channels .ReadableByteChannel ;
@@ -669,17 +670,9 @@ private FrameMetaData getFrameMetaData(ByteBuffer frameHeader)
669670 private FrameData getFrameData (ByteBuffer content )
670671 throws IOException
671672 {
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 );
684677 }
685678}
You can’t perform that action at this time.
0 commit comments