@matheusbsbs / matheus-bagliano / commits / f5948cfe67
Fork 0

count-delta: no need for this anymore.

This is a companion patch to e29e1147e485654d90a0ea0fd5fb7151bb194265 which made diffcore similarity estimator independent from the packfile deltifier. There is no reason for us to be counting the xdelta anymore. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Mar 4, 2006 at 02:51 UTC f5948cfe673ec65c09b926249cc02ab4451243fa
3 files changed +2 -84
Makefile
+2 -2
@@ -190,7 +190,7 @@ PYMODULES = \
190 LIB_FILE=libgit.a
191
192 LIB_H = \
193 - blob.h cache.h commit.h count-delta.h csum-file.h delta.h \
193 + blob.h cache.h commit.h csum-file.h delta.h \
194 diff.h object.h pack.h pkt-line.h quote.h refs.h \
195 run-command.h strbuf.h tag.h tree.h git-compat-util.h revision.h
196
@@ -200,7 +200,7 @@ DIFF_OBJS = \
200 diffcore-delta.o
201
202 LIB_OBJS = \
203 - blob.o commit.o connect.o count-delta.o csum-file.o \
203 + blob.o commit.o connect.o csum-file.o \
204 date.o diff-delta.o entry.o exec_cmd.o ident.o index.o \
205 object.o pack-check.o patch-delta.o path.o pkt-line.o \
206 quote.o read-cache.o refs.o run-command.o \
count-delta.c deleted
-72
@@ -1,72 +0,0 @@
1 -/*
2 - * Copyright (C) 2005 Junio C Hamano
3 - * The delta-parsing part is almost straight copy of patch-delta.c
4 - * which is (C) 2005 Nicolas Pitre <nico@cam.org>.
5 - */
6 -#include <stdlib.h>
7 -#include <string.h>
8 -#include <limits.h>
9 -#include "delta.h"
10 -#include "count-delta.h"
11 -
12 -/*
13 - * NOTE. We do not _interpret_ delta fully. As an approximation, we
14 - * just count the number of bytes that are copied from the source, and
15 - * the number of literal data bytes that are inserted.
16 - *
17 - * Number of bytes that are _not_ copied from the source is deletion,
18 - * and number of inserted literal bytes are addition, so sum of them
19 - * is the extent of damage.
20 - */
21 -int count_delta(void *delta_buf, unsigned long delta_size,
22 - unsigned long *src_copied, unsigned long *literal_added)
23 -{
24 - unsigned long copied_from_source, added_literal;
25 - const unsigned char *data, *top;
26 - unsigned char cmd;
27 - unsigned long src_size, dst_size, out;
28 -
29 - if (delta_size < DELTA_SIZE_MIN)
30 - return -1;
31 -
32 - data = delta_buf;
33 - top = delta_buf + delta_size;
34 -
35 - src_size = get_delta_hdr_size(&data);
36 - dst_size = get_delta_hdr_size(&data);
37 -
38 - added_literal = copied_from_source = out = 0;
39 - while (data < top) {
40 - cmd = *data++;
41 - if (cmd & 0x80) {
42 - unsigned long cp_off = 0, cp_size = 0;
43 - if (cmd & 0x01) cp_off = *data++;
44 - if (cmd & 0x02) cp_off |= (*data++ << 8);
45 - if (cmd & 0x04) cp_off |= (*data++ << 16);
46 - if (cmd & 0x08) cp_off |= (*data++ << 24);
47 - if (cmd & 0x10) cp_size = *data++;
48 - if (cmd & 0x20) cp_size |= (*data++ << 8);
49 - if (cmd & 0x40) cp_size |= (*data++ << 16);
50 - if (cp_size == 0) cp_size = 0x10000;
51 -
52 - copied_from_source += cp_size;
53 - out += cp_size;
54 - } else {
55 - /* write literal into dst */
56 - added_literal += cmd;
57 - out += cmd;
58 - data += cmd;
59 - }
60 - }
61 -
62 - /* sanity check */
63 - if (data != top || out != dst_size)
64 - return -1;
65 -
66 - /* delete size is what was _not_ copied from source.
67 - * edit size is that and literal additions.
68 - */
69 - *src_copied = copied_from_source;
70 - *literal_added = added_literal;
71 - return 0;
72 -}
count-delta.h deleted
-10
@@ -1,10 +0,0 @@
1 -/*
2 - * Copyright (C) 2005 Junio C Hamano
3 - */
4 -#ifndef COUNT_DELTA_H
5 -#define COUNT_DELTA_H
6 -
7 -int count_delta(void *, unsigned long,
8 - unsigned long *src_copied, unsigned long *literal_added);
9 -
10 -#endif