Commit 024319d6 authored by Rob Swindell's avatar Rob Swindell 💬
Browse files

Speed up list_archive_contents()

Don't use iniSet* since we know we're not updating existing ini entries. Use strListAppendFormat() instead.
parent 498187eb
Pipeline #2155 passed with stage
in 8 minutes and 20 seconds
......@@ -764,12 +764,13 @@ str_list_t list_archive_contents(const char* filename, const char* pattern, bool
iniSetString(&list, pathname, "type", type, /* style: */NULL);
iniSetBytes(&list, pathname, "size", 1, archive_entry_size(entry), /* style: */NULL);
iniSetDateTime(&list, pathname, "time", true, archive_entry_mtime(entry), NULL);
iniSetInteger(&list, pathname, "mode", archive_entry_mode(entry), NULL);
iniSetString(&list, pathname, "format", archive_format_name(ar), NULL);
iniSetString(&list, pathname, "compression", archive_filter_name(ar, 0), NULL);
strListAppendFormat(&list, "[%s]", pathname);
strListAppendFormat(&list, "type=%s", type);
strListAppendFormat(&list, "size=%"PRId64, archive_entry_size(entry));
strListAppendFormat(&list, "time=%"PRId64,archive_entry_mtime(entry));
strListAppendFormat(&list, "mode=%d", archive_entry_mode(entry));
strListAppendFormat(&list, "format=%s", archive_format_name(ar));
strListAppendFormat(&list, "compression=%s", archive_filter_name(ar, 0));
if(hash && archive_entry_filetype(entry) == AE_IFREG) {
MD5 md5_ctx;
......@@ -795,10 +796,10 @@ str_list_t list_archive_contents(const char* filename, const char* pattern, bool
MD5_close(&md5_ctx, md5);
SHA1Final(&sha1_ctx, sha1);
iniSetHexInt(&list, pathname, "crc32", crc32, NULL);
strListAppendFormat(&list, "crc32=0x%lx", crc32);
char hex[128];
iniSetString(&list, pathname, "md5", MD5_hex(hex, md5), NULL);
iniSetString(&list, pathname, "sha1", SHA1_hex(hex, sha1), NULL);
strListAppendFormat(&list, "md5=%s", MD5_hex(hex, md5));
strListAppendFormat(&list, "sha1=%s", SHA1_hex(hex, sha1));
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment