From e8b2d199148cc311fc42c0f9cb4fe39ef5257e23 Mon Sep 17 00:00:00 2001 From: Mateusz Moscicki Date: Tue, 8 Mar 2022 11:52:32 +0100 Subject: [PATCH] Add two additional offsets while trying to create a patch Creating a patch with an offset score equal to 8 may take too long. On the other hand for a value of 2 the resulting patch will consist of multiple blocks, which can significantly increase the application time. Therefore this commit adds two intermediate steps as a compromise solution. Change-Id: Id90beba4c4c89e20fb5f377f1499fb308e9f36a1 --- bsdiff/ss_bsdiff.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/bsdiff/ss_bsdiff.c b/bsdiff/ss_bsdiff.c index 209f2e9..0cef267 100755 --- a/bsdiff/ss_bsdiff.c +++ b/bsdiff/ss_bsdiff.c @@ -723,13 +723,16 @@ int MY_CDECL main(int argc, char *argv[]) int ret = create_patch(info.old_file, info.new_file, TEMP_PATCH_NAME, 8); #ifdef TIME_LIMIT_CHECK - if (ret != 0) { - printf("Trying with offset score 2\n"); - ret = create_patch(info.old_file, info.new_file, TEMP_PATCH_NAME, 2); - } - if (ret != 0) { - printf("Trying with offset score 0\n"); - ret = create_patch(info.old_file, info.new_file, TEMP_PATCH_NAME, 0); + /* + * Creating a patch with an offset score equal to 8 may take too long. On + * the other hand for a value of 2 the resulting patch will consist of + * multiple blocks, which can significantly increase the application time. + * Therefore this commit adds two intermediate steps as a compromise + * solution. + */ + for (int score = 6; score >= 0 && ret != 0; score-=2) { + printf("Trying with offset score %d\n", score); + ret = create_patch(info.old_file, info.new_file, TEMP_PATCH_NAME, score); } if (ret != 0) err(1, "bsdiff fails to create delta within timelimit"); -- 2.7.4