aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2003-11-14 08:26:25 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2003-11-14 08:26:25 +0000
commitd09bcecda80d601a467f73d75a42991b0a6dca68 (patch)
tree487386c7cc0c62abbff34938e8bb6f2110c7d770
parent5f28455c6efe9c86d96d216a5bdc7f6db3e85780 (diff)
downloadbusybox-w32-d09bcecda80d601a467f73d75a42991b0a6dca68.tar.gz
busybox-w32-d09bcecda80d601a467f73d75a42991b0a6dca68.tar.bz2
busybox-w32-d09bcecda80d601a467f73d75a42991b0a6dca68.zip
Read in blocks rather than one char at a time, greatly improves speed
-rw-r--r--archival/libunarchive/seek_by_char.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/archival/libunarchive/seek_by_char.c b/archival/libunarchive/seek_by_char.c
index f33935cb5..77da4ef2e 100644
--- a/archival/libunarchive/seek_by_char.c
+++ b/archival/libunarchive/seek_by_char.c
@@ -14,12 +14,31 @@
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15 */ 15 */
16 16
17#include <stdlib.h>
18
17#include "unarchive.h" 19#include "unarchive.h"
20#include "busybox.h"
18 21
19extern void seek_by_char(const archive_handle_t *archive_handle, const unsigned int amount) 22/* If we are reading through a pipe(), or from stdin then we cant lseek,
23 * we must read and discard the data to skip over it.
24 *
25 * TODO: rename to seek_by_read
26 */
27extern void seek_by_char(const archive_handle_t *archive_handle, const unsigned int jump_size)
20{ 28{
21 unsigned int i; 29 unsigned int remaining = jump_size;
22 for (i = 0; i < amount; i++) { 30 unsigned int read_amount;
23 archive_xread_char(archive_handle); 31 RESERVE_CONFIG_BUFFER(buf, BUFSIZ);
32
33 while (remaining > 0) {
34 if (remaining > BUFSIZ) {
35 read_amount = BUFSIZ;
36 } else {
37 read_amount = remaining;
38 }
39 read_amount = archive_xread(archive_handle, buf, read_amount);
40 remaining -= read_amount;
24 } 41 }
42
43 RELEASE_CONFIG_BUFFER(buf);
25} 44}