Merge branch 'np/pack' into next
authorJunio C Hamano <junkio@cox.net>
Tue, 16 May 2006 21:50:26 +0000 (14:50 -0700)
committerJunio C Hamano <junkio@cox.net>
Tue, 16 May 2006 21:50:26 +0000 (14:50 -0700)
* np/pack:
improve depth heuristic for maximum delta size

1  2 
pack-objects.c
diff --combined pack-objects.c
index 566a2a2349871d05378b1b8de27d315b7451f89c,33751797fa33706f95f21011a523b021093e2e75..77284cfdbaef108676c95bd4d9771e40080fd406
@@@ -10,6 -10,7 +10,6 @@@
  #include "tree-walk.h"
  #include <sys/time.h>
  #include <signal.h>
 -#include <stdint.h>
  
  static const char pack_usage[] = "git-pack-objects [-q] [--no-reuse-delta] [--non-empty] [--local] [--incremental] [--window=N] [--depth=N] {--stdout | base-name} < object-list";
  
@@@ -156,7 -157,7 +156,7 @@@ static void prepare_pack_revindex(struc
  
        rix->revindex = xmalloc(sizeof(unsigned long) * (num_ent + 1));
        for (i = 0; i < num_ent; i++) {
 -              uint32_t hl = *((uint32_t *)(index + 24 * i));
 +              unsigned int hl = *((unsigned int *)(index + 24 * i));
                rix->revindex[i] = ntohl(hl);
        }
        /* This knows the pack format -- the 20-byte trailer
@@@ -1036,9 -1037,12 +1036,12 @@@ static int try_delta(struct unpacked *t
        if (src_entry->depth >= max_depth)
                return 0;
  
-       /* Now some size filtering euristics. */
+       /* Now some size filtering heuristics. */
        size = trg_entry->size;
-       max_size = (size/2 - 20) / (src_entry->depth + 1);
+       max_size = size/2 - 20;
+       max_size = max_size * (max_depth - src_entry->depth) / max_depth;
+       if (max_size == 0)
+               return 0;
        if (trg_entry->delta && trg_entry->delta_size <= max_size)
                max_size = trg_entry->delta_size-1;
        src_size = src_entry->size;