mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Remove stream CRC and optimize CRC compute CRC32C using two lanes
This commit is contained in:
parent
581ec4e156
commit
a01ec45f14
7 changed files with 196 additions and 129 deletions
|
|
@ -68,7 +68,6 @@ STREAM* sopen_read(const char* file, int flags)
|
|||
s->offset_uncached = 0;
|
||||
s->crc = 0;
|
||||
s->crc_uncached = 0;
|
||||
s->crc_stream = CRC_IV;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
@ -100,7 +99,6 @@ STREAM* sopen_multi_write(unsigned count, int flags)
|
|||
s->offset_uncached = 0;
|
||||
s->crc = 0;
|
||||
s->crc_uncached = 0;
|
||||
s->crc_stream = CRC_IV;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
@ -389,12 +387,6 @@ uint32_t scrc(STREAM* s)
|
|||
return crc32c(s->crc_uncached, s->buffer, s->pos - s->buffer);
|
||||
}
|
||||
|
||||
uint32_t scrc_stream(STREAM* s)
|
||||
{
|
||||
assert(s->flags & STREAM_FLAGS_CRC);
|
||||
return s->crc_stream ^ CRC_IV;
|
||||
}
|
||||
|
||||
int sgetc_uncached(STREAM* s)
|
||||
{
|
||||
/* if at the end of the buffer, fill it */
|
||||
|
|
@ -735,10 +727,6 @@ int swrite_uncached(const void* void_data, size_t size, STREAM* f)
|
|||
if (available > size)
|
||||
available = size;
|
||||
|
||||
/* compute the independent CRC before copying to detect buffer corruption */
|
||||
if (f->flags & STREAM_FLAGS_CRC)
|
||||
f->crc_stream = crc32c_plain(f->crc_stream, data, available);
|
||||
|
||||
memcpy(f->pos, data, available);
|
||||
f->pos += available;
|
||||
data += available;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue