hash,compress.gzip: speedup .gz decompression with tcc, for VTL's mnist_test.v and imdb_test.v (without -prod)

This commit is contained in:
Delyan Angelov 2024-12-17 17:49:19 +02:00
parent 00148d11fc
commit 8835b6f2db
No known key found for this signature in database
GPG key ID: 66886C0F12D595ED
2 changed files with 5 additions and 2 deletions

View file

@ -69,6 +69,7 @@ pub mut:
}
// validate validates the header and returns its details if valid
@[direct_array_access]
pub fn validate(data []u8, params DecompressParams) !GzipHeader {
if data.len < min_header_length {
return error('data is too short, not gzip compressed?')

View file

@ -35,6 +35,7 @@ fn (mut c Crc32) generate_table(poly int) {
}
}
@[direct_array_access]
fn (c &Crc32) sum32(b []u8) u32 {
mut crc := ~u32(0)
for i in 0 .. b.len {
@ -56,8 +57,9 @@ pub fn new(poly int) &Crc32 {
return c
}
const ieee_poly = new(int(ieee))
// sum calculates the CRC-32 checksum of `b` by using the IEEE polynomial.
pub fn sum(b []u8) u32 {
c := new(int(ieee))
return c.sum32(b)
return ieee_poly.sum32(b)
}