mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +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
|
||||
@[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?')
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue