From: Tim Kientzle Date: Sun, 29 Dec 2013 18:45:41 +0000 (-0800) Subject: Optimize skipping entries in seeking mode X-Git-Tag: v3.1.900a~327^2~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ff6835b9400c50b2512a2e1a64f8eae0bdc6de51;p=thirdparty%2Flibarchive.git Optimize skipping entries in seeking mode --- diff --git a/libarchive/archive_read_support_format_zip.c b/libarchive/archive_read_support_format_zip.c index 593e87e37..df477b1cb 100644 --- a/libarchive/archive_read_support_format_zip.c +++ b/libarchive/archive_read_support_format_zip.c @@ -145,6 +145,7 @@ static int archive_read_format_zip_cleanup(struct archive_read *); static int archive_read_format_zip_read_data(struct archive_read *, const void **, size_t *, int64_t *); static int archive_read_format_zip_read_data_skip(struct archive_read *a); +static int archive_read_format_zip_read_data_skip_seekable(struct archive_read *a); static int archive_read_format_zip_seekable_read_header( struct archive_read *, struct archive_entry *); static int archive_read_format_zip_streamable_read_header( @@ -253,7 +254,7 @@ archive_read_support_format_zip_seekable(struct archive *_a) archive_read_format_zip_options, archive_read_format_zip_seekable_read_header, archive_read_format_zip_read_data, - archive_read_format_zip_read_data_skip, + archive_read_format_zip_read_data_skip_seekable, NULL, archive_read_format_zip_cleanup, archive_read_support_format_zip_capabilities_seekable, @@ -1775,6 +1776,21 @@ zip_read_data_deflate(struct archive_read *a, const void **buff, } #endif +/* + * We're going to seek for the next header anyway, so we don't + * need to bother doing anything here. + */ +static int +archive_read_format_zip_read_data_skip_seekable(struct archive_read *a) +{ + struct zip *zip; + zip = (struct zip *)(a->format->data); + + zip->unconsumed = 0; + return (ARCHIVE_OK); +} + + static int archive_read_format_zip_read_data_skip(struct archive_read *a) {