summaryrefslogtreecommitdiff
path: root/libarchive/archive_read_support_format_cab.c
diff options
context:
space:
mode:
authorTim Kientzle <kientzle@gmail.com>2011-11-20 19:52:32 -0500
committerTim Kientzle <kientzle@gmail.com>2011-11-20 19:52:32 -0500
commitbb44a73ac7ea4f0efee36ad41b2a3ec6e43ea512 (patch)
tree33f8745979cce92e392fa564fbf577fe5136f6b5 /libarchive/archive_read_support_format_cab.c
parent799f4d1756c1ccb5656d037f1ebd5e6ed37c0ead (diff)
downloadlibarchive-bb44a73ac7ea4f0efee36ad41b2a3ec6e43ea512.tar.gz
Try to decrease the performance hit of seeking during the bid phase.
Tell each bidder about the best bid so far so it can decide to do nothing. Reorder support_format_all so formats with relatively inexpensive bidders will run first. SVN-Revision: 3822
Diffstat (limited to 'libarchive/archive_read_support_format_cab.c')
-rw-r--r--libarchive/archive_read_support_format_cab.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libarchive/archive_read_support_format_cab.c b/libarchive/archive_read_support_format_cab.c
index ff87dcef..f932fadf 100644
--- a/libarchive/archive_read_support_format_cab.c
+++ b/libarchive/archive_read_support_format_cab.c
@@ -313,7 +313,7 @@ struct cab {
struct lzx_stream xstrm;
};
-static int archive_read_format_cab_bid(struct archive_read *);
+static int archive_read_format_cab_bid(struct archive_read *, int);
static int archive_read_format_cab_options(struct archive_read *,
const char *, const char *);
static int archive_read_format_cab_read_header(struct archive_read *,
@@ -415,11 +415,16 @@ find_cab_magic(const char *p)
}
static int
-archive_read_format_cab_bid(struct archive_read *a)
+archive_read_format_cab_bid(struct archive_read *a, int best_bid)
{
const char *p;
ssize_t bytes_avail, offset, window;
+ /* If there's already a better bid than we can ever
+ make, don't bother testing. */
+ if (best_bid > 64)
+ return (-1);
+
if ((p = __archive_read_ahead(a, 8, NULL)) == NULL)
return (-1);