Read in blocks rather than one char at a time, greatly improves speed
This commit is contained in:
parent
5f28455c6e
commit
d09bcecda8
@ -14,12 +14,31 @@
|
|||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "unarchive.h"
|
#include <stdlib.h>
|
||||||
|
|
||||||
extern void seek_by_char(const archive_handle_t *archive_handle, const unsigned int amount)
|
#include "unarchive.h"
|
||||||
|
#include "busybox.h"
|
||||||
|
|
||||||
|
/* If we are reading through a pipe(), or from stdin then we cant lseek,
|
||||||
|
* we must read and discard the data to skip over it.
|
||||||
|
*
|
||||||
|
* TODO: rename to seek_by_read
|
||||||
|
*/
|
||||||
|
extern void seek_by_char(const archive_handle_t *archive_handle, const unsigned int jump_size)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int remaining = jump_size;
|
||||||
for (i = 0; i < amount; i++) {
|
unsigned int read_amount;
|
||||||
archive_xread_char(archive_handle);
|
RESERVE_CONFIG_BUFFER(buf, BUFSIZ);
|
||||||
|
|
||||||
|
while (remaining > 0) {
|
||||||
|
if (remaining > BUFSIZ) {
|
||||||
|
read_amount = BUFSIZ;
|
||||||
|
} else {
|
||||||
|
read_amount = remaining;
|
||||||
|
}
|
||||||
|
read_amount = archive_xread(archive_handle, buf, read_amount);
|
||||||
|
remaining -= read_amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RELEASE_CONFIG_BUFFER(buf);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user