mirror of
https://github.com/ckolivas/lrzip.git
synced 2025-12-06 07:12:00 +01:00
Cache the chunk bytes value to avoid setting it on each read_header call
This commit is contained in:
parent
707ca69d31
commit
6e31fc621e
|
|
@ -444,6 +444,7 @@ struct rzip_control {
|
|||
void (*log_cb)(void *data, unsigned int level, unsigned int line, const char *file, const char *func, const char *format, va_list);
|
||||
void *log_data;
|
||||
|
||||
char chunk_bytes;
|
||||
struct sliding_buffer sb;
|
||||
void (*do_mcpy)(rzip_control *, unsigned char *, i64, i64);
|
||||
void (*next_tag)(rzip_control *, struct rzip_state *, i64, tag *);
|
||||
|
|
|
|||
14
runzip.c
14
runzip.c
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 2006-2012 Con Kolivas
|
||||
Copyright (C) 2006-2015 Con Kolivas
|
||||
Copyright (C) 1998-2003 Andrew Tridgell
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
@ -139,16 +139,12 @@ static i64 seekto_fdinend(rzip_control *control)
|
|||
|
||||
static i64 read_header(rzip_control *control, void *ss, uchar *head)
|
||||
{
|
||||
int chunk_bytes = 2;
|
||||
bool err = false;
|
||||
|
||||
/* All chunks were unnecessarily encoded 8 bytes wide version 0.4x */
|
||||
if (control->major_version == 0 && control->minor_version == 4)
|
||||
chunk_bytes = 8;
|
||||
*head = read_u8(control, ss, 0, &err);
|
||||
if (err)
|
||||
return -1;
|
||||
return read_vchars(control, ss, 0, chunk_bytes);
|
||||
return read_vchars(control, ss, 0, control->chunk_bytes);
|
||||
}
|
||||
|
||||
static i64 unzip_literal(rzip_control *control, void *ss, i64 len, uint32 *cksum)
|
||||
|
|
@ -309,6 +305,12 @@ static i64 runzip_chunk(rzip_control *control, int fd_in, i64 expected_size, i64
|
|||
if (unlikely(!ss))
|
||||
failure_return(("Failed to open_stream_in in runzip_chunk\n"), -1);
|
||||
|
||||
/* All chunks were unnecessarily encoded 8 bytes wide version 0.4x */
|
||||
if (control->major_version == 0 && control->minor_version == 4)
|
||||
control->chunk_bytes = 8;
|
||||
else
|
||||
control->chunk_bytes = 2;
|
||||
|
||||
while ((len = read_header(control, ss, &head)) || head) {
|
||||
i64 u;
|
||||
if (unlikely(len == -1))
|
||||
|
|
|
|||
Loading…
Reference in a new issue