access CRC tab directly
This commit is contained in:
parent
4e359bdfea
commit
cd01df9c64
|
@ -275,7 +275,6 @@ string BinaryReader::readMultibyteTerminatedStringLE(size_t maxBytesToRead, uint
|
|||
*/
|
||||
uint32 BinaryReader::readCrc32(size_t length)
|
||||
{
|
||||
uint32 *crc32Table = BinaryReader::crc32Table();
|
||||
uint32 crc = 0x00;
|
||||
for(uint32 i = 0; i < length; ++i) {
|
||||
crc = (crc << 8) ^ crc32Table[((crc >> 24) & 0xff) ^ static_cast<byte>(m_stream->get())];
|
||||
|
@ -284,15 +283,11 @@ uint32 BinaryReader::readCrc32(size_t length)
|
|||
}
|
||||
|
||||
/*!
|
||||
* \brief Returns a CRC-32 table.
|
||||
*
|
||||
* \brief CRC-32 table.
|
||||
* \remarks Internally used by readCrc32() method.
|
||||
*
|
||||
* \sa readCrc32()
|
||||
*/
|
||||
uint32 *BinaryReader::crc32Table()
|
||||
{
|
||||
static uint32 table[] = {
|
||||
const uint32 BinaryReader::crc32Table[] = {
|
||||
0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
|
||||
0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61,
|
||||
0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, 0x4c11db70, 0x48d0c6c7,
|
||||
|
@ -337,6 +332,4 @@ uint32 *BinaryReader::crc32Table()
|
|||
0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668,
|
||||
0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
|
||||
};
|
||||
return table;
|
||||
}
|
||||
|
||||
|
|
|
@ -75,8 +75,8 @@ public:
|
|||
float32 readFixed8LE();
|
||||
float32 readFixed16LE();
|
||||
uint32 readCrc32(std::size_t length);
|
||||
static uint32 *crc32Table();
|
||||
static uint32 computeCrc32(const char *buffer, std::size_t length);
|
||||
static const uint32 crc32Table[];
|
||||
|
||||
private:
|
||||
std::istream *m_stream;
|
||||
|
|
Loading…
Reference in New Issue