diff options
author | Timo Teras <timo.teras@iki.fi> | 2009-07-17 15:56:09 +0300 |
---|---|---|
committer | Timo Teras <timo.teras@iki.fi> | 2009-07-17 15:56:09 +0300 |
commit | e30834fdcbaf8b273f6e6eed411dec580bfbb4dd (patch) | |
tree | b546145cd915eb8233ece0b8effed56ff111fff1 /src/io.c | |
parent | 0942832325f8e81d9e3cc7019cf1b1016d226533 (diff) | |
download | apk-tools-e30834fdcbaf8b273f6e6eed411dec580bfbb4dd.tar.gz apk-tools-e30834fdcbaf8b273f6e6eed411dec580bfbb4dd.tar.bz2 apk-tools-e30834fdcbaf8b273f6e6eed411dec580bfbb4dd.tar.xz apk-tools-e30834fdcbaf8b273f6e6eed411dec580bfbb4dd.zip |
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.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -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); |