Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit a1c17f3

Browse files
committed
Add additional code comments about some magic numbers
These values originate from Colin's paper directly, but I think more data-driven testing and analysis is needed to determine whether the values are generally optimal. Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
1 parent 9807f60 commit a1c17f3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/diff.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,9 @@ int make_bsdiff_delta(char *old_filename, char *new_filename, char *delta_filena
611611
// previous exact match. A score (old_score) is used to track
612612
// how many bytes match starting from new_pos in new, and from
613613
// old_pos in the previous iteration.
614+
// NOTE: the magic value 8 is a heuristic; further testing is
615+
// needed to prove whether this is the best number, or if the
616+
// number should vary according to other factors, etc.
614617
int64_t old_score = 0;
615618
int64_t new_peek;
616619
for (new_peek = new_pos += match_len; new_pos < new_size; new_pos++) {
@@ -647,6 +650,11 @@ int make_bsdiff_delta(char *old_filename, char *new_filename, char *delta_filena
647650
// half of the bytes match between old and new. This
648651
// fuzzy match will be used to construct a diff string
649652
// in the diff block.
653+
// NOTE: "at least half matching bytes" is a heuristic
654+
// for both fuzzy regions being constructed below;
655+
// further testing is needed to prove whether this is
656+
// the best percentage, or if the percentage should
657+
// vary according to other factors, etc.
650658
int64_t len_fuzzyforward = 0;
651659
for (int64_t i = 0;
652660
(last_new_pos + i < new_pos) && (last_old_pos + i < old_size);) {

0 commit comments

Comments
 (0)