diff options
author | Alex Deymo <deymo@google.com> | 2018-02-08 15:50:11 +0100 |
---|---|---|
committer | Alex Deymo <deymo@google.com> | 2018-02-12 17:20:51 +0100 |
commit | 383f677d7e0d9e8e5a967c5451f5f6a663f222c6 (patch) | |
tree | f8eb510cb524d41c4f53e420ed6c0bdcfcbc46d5 /bsdiff_main.cc | |
parent | 6c53ba8a18007181f167acfe12d456cc87081fad (diff) | |
download | bsdiff-383f677d7e0d9e8e5a967c5451f5f6a663f222c6.tar.gz |
Allow to set the minimum required match length.
The minimum required match length plays an important role in the
current algorithm. This algorithm requires that the current match
has at least 8 mismatches over a region where we find a new match,
therefore imposing a minimum match length of at least 8 bytes.
This patch allows to increase this minium value to avoid using small
matches that only match a very small region. A larger value can
improve the patch size, depending on the data, but a too large value
will cause the algorithm to miss matches that were otherwise benefical.
Bug: 73107113
Test: Added unittests. Ran it with different minlen values.
Change-Id: Iac594fc1cd7ecd5cfdc676bdb6ebe7c626de6dcd
Diffstat (limited to 'bsdiff_main.cc')
-rw-r--r-- | bsdiff_main.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/bsdiff_main.cc b/bsdiff_main.cc index bce9453..1465441 100644 --- a/bsdiff_main.cc +++ b/bsdiff_main.cc @@ -85,8 +85,8 @@ int GenerateBsdiffFromFiles(const char* old_filename, return 1; } - return bsdiff::bsdiff(old_buf, oldsize, new_buf, newsize, patch_writer.get(), - nullptr); + return bsdiff::bsdiff(old_buf, oldsize, new_buf, newsize, + arguments.min_length(), patch_writer.get(), nullptr); } void PrintUsage(const std::string& proc_name) { @@ -94,6 +94,8 @@ void PrintUsage(const std::string& proc_name) { << " [options] oldfile newfile patchfile\n"; std::cerr << " --format <legacy|bsdiff40|bsdf2> The format of the bsdiff" " patch.\n" + << " --minlen LEN The minimum match length required " + "to consider a match in the algorithm.\n" << " --type <bz2|brotli> The algorithm to compress the " "patch, bsdf2 format only.\n" << " --quality Quality of the patch compression," |