diff options
author | Junio C Hamano <gitster@pobox.com> | 2007-09-14 18:33:45 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-09-14 18:33:45 -0700 |
commit | 357c5e086c28581918329281be18ab236d33967f (patch) | |
tree | 187b316ce7168eef3f8d496732b7e61c7b4eda08 | |
parent | Merge branch 'dk/diff-delta' (diff) | |
parent | Keep last used delta base in the delta window (diff) | |
download | tgif-357c5e086c28581918329281be18ab236d33967f.tar.xz |
Merge branch 'jc/pack'
* jc/pack:
Keep last used delta base in the delta window
-rw-r--r-- | builtin-pack-objects.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c index 12509faa77..e64e3a03a0 100644 --- a/builtin-pack-objects.c +++ b/builtin-pack-objects.c @@ -1460,7 +1460,7 @@ static void find_deltas(struct object_entry **list, int window, int depth) do { struct object_entry *entry = list[--i]; struct unpacked *n = array + idx; - int j; + int j, best_base = -1; if (!entry->preferred_base) processed++; @@ -1505,6 +1505,7 @@ static void find_deltas(struct object_entry **list, int window, int depth) j = window; while (--j > 0) { + int ret; uint32_t other_idx = idx + j; struct unpacked *m; if (other_idx >= window) @@ -1512,8 +1513,11 @@ static void find_deltas(struct object_entry **list, int window, int depth) m = array + other_idx; if (!m->entry) break; - if (try_delta(n, m, max_depth) < 0) + ret = try_delta(n, m, max_depth); + if (ret < 0) break; + else if (ret > 0) + best_base = other_idx; } /* if we made n a delta, and if n is already at max @@ -1523,6 +1527,23 @@ static void find_deltas(struct object_entry **list, int window, int depth) if (entry->delta && depth <= n->depth) continue; + /* + * Move the best delta base up in the window, after the + * currently deltified object, to keep it longer. It will + * be the first base object to be attempted next. + */ + if (entry->delta) { + struct unpacked swap = array[best_base]; + int dist = (window + idx - best_base) % window; + int dst = best_base; + while (dist--) { + int src = (dst + 1) % window; + array[dst] = array[src]; + dst = src; + } + array[dst] = swap; + } + next: idx++; if (count + 1 < window) |