mirror of
https://github.com/vlang/v.git
synced 2025-09-14 06:52:36 +03:00
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:
parent
00148d11fc
commit
8835b6f2db
2 changed files with 5 additions and 2 deletions
|
@ -69,6 +69,7 @@ pub mut:
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate validates the header and returns its details if valid
|
// validate validates the header and returns its details if valid
|
||||||
|
@[direct_array_access]
|
||||||
pub fn validate(data []u8, params DecompressParams) !GzipHeader {
|
pub fn validate(data []u8, params DecompressParams) !GzipHeader {
|
||||||
if data.len < min_header_length {
|
if data.len < min_header_length {
|
||||||
return error('data is too short, not gzip compressed?')
|
return error('data is too short, not gzip compressed?')
|
||||||
|
|
|
@ -35,6 +35,7 @@ fn (mut c Crc32) generate_table(poly int) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@[direct_array_access]
|
||||||
fn (c &Crc32) sum32(b []u8) u32 {
|
fn (c &Crc32) sum32(b []u8) u32 {
|
||||||
mut crc := ~u32(0)
|
mut crc := ~u32(0)
|
||||||
for i in 0 .. b.len {
|
for i in 0 .. b.len {
|
||||||
|
@ -56,8 +57,9 @@ pub fn new(poly int) &Crc32 {
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ieee_poly = new(int(ieee))
|
||||||
|
|
||||||
// sum calculates the CRC-32 checksum of `b` by using the IEEE polynomial.
|
// sum calculates the CRC-32 checksum of `b` by using the IEEE polynomial.
|
||||||
pub fn sum(b []u8) u32 {
|
pub fn sum(b []u8) u32 {
|
||||||
c := new(int(ieee))
|
return ieee_poly.sum32(b)
|
||||||
return c.sum32(b)
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue