summaryrefslogtreecommitdiffstats
path: root/src/io.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-07-17 15:56:09 +0300
committerTimo Teras <timo.teras@iki.fi>2009-07-17 15:56:09 +0300
commite30834fdcbaf8b273f6e6eed411dec580bfbb4dd (patch)
treeb546145cd915eb8233ece0b8effed56ff111fff1 /src/io.c
parent0942832325f8e81d9e3cc7019cf1b1016d226533 (diff)
digest: use oneshot context flag where approriate
speeds up digest calculation on some cases.
Diffstat (limited to 'src/io.c')
-rw-r--r--src/io.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/io.c b/src/io.c
index c7846c9..e7ed16e 100644
--- a/src/io.c
+++ b/src/io.c
@@ -295,6 +295,7 @@ static struct apk_bstream *apk_mmap_bstream_from_fd(int fd)
}
mbs->bs = (struct apk_bstream) {
+ .flags = APK_BSTREAM_SINGLE_READ,
.read = mmap_read,
.close = mmap_close,
};
@@ -466,6 +467,8 @@ int apk_file_get_info(const char *filename, int checksum, struct apk_file_info *
apk_blob_t blob;
EVP_DigestInit(&mdctx, apk_get_digest(checksum));
+ if (bs->flags & APK_BSTREAM_SINGLE_READ)
+ EVP_MD_CTX_set_flags(&mdctx, EVP_MD_CTX_FLAG_ONESHOT);
while (!APK_BLOB_IS_NULL(blob = bs->read(bs, APK_BLOB_NULL)))
EVP_DigestUpdate(&mdctx, (void*) blob.ptr, blob.len);
fi->csum.type = EVP_MD_CTX_size(&mdctx);