Skip to content

Commit d8c3d03

Browse files
committed
diffcore_count_changes: pass diffcore_filespec
We may want to use richer information on the data we are dealing with in this function, so instead of passing a buffer address and length, just pass the diffcore_filespec structure. Existing callers always call this function with parameters taken from a filespec anyway, so there is no functionality changes. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 06f59e9 commit d8c3d03

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

diffcore-break.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ static int should_break(struct diff_filespec *src,
6666
if (base_size < MINIMUM_BREAK_SIZE)
6767
return 0; /* we do not break too small filepair */
6868

69-
if (diffcore_count_changes(src->data, src->size,
70-
dst->data, dst->size,
69+
if (diffcore_count_changes(src, dst,
7170
NULL, NULL,
7271
0,
7372
&src_copied, &literal_added))

diffcore-delta.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ static struct spanhash_top *hash_chars(unsigned char *buf, unsigned int sz)
156156
return hash;
157157
}
158158

159-
int diffcore_count_changes(void *src, unsigned long src_size,
160-
void *dst, unsigned long dst_size,
159+
int diffcore_count_changes(struct diff_filespec *src,
160+
struct diff_filespec *dst,
161161
void **src_count_p,
162162
void **dst_count_p,
163163
unsigned long delta_limit,
@@ -172,14 +172,14 @@ int diffcore_count_changes(void *src, unsigned long src_size,
172172
if (src_count_p)
173173
src_count = *src_count_p;
174174
if (!src_count) {
175-
src_count = hash_chars(src, src_size);
175+
src_count = hash_chars(src->data, src->size);
176176
if (src_count_p)
177177
*src_count_p = src_count;
178178
}
179179
if (dst_count_p)
180180
dst_count = *dst_count_p;
181181
if (!dst_count) {
182-
dst_count = hash_chars(dst, dst_size);
182+
dst_count = hash_chars(dst->data, dst->size);
183183
if (dst_count_p)
184184
*dst_count_p = dst_count;
185185
}

diffcore-rename.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,7 @@ static int estimate_similarity(struct diff_filespec *src,
189189

190190
delta_limit = (unsigned long)
191191
(base_size * (MAX_SCORE-minimum_score) / MAX_SCORE);
192-
if (diffcore_count_changes(src->data, src->size,
193-
dst->data, dst->size,
192+
if (diffcore_count_changes(src, dst,
194193
&src->cnt_data, &dst->cnt_data,
195194
delta_limit,
196195
&src_copied, &literal_added))

diffcore.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ void diff_debug_queue(const char *, struct diff_queue_struct *);
103103
#define diff_debug_queue(a,b) do {} while(0)
104104
#endif
105105

106-
extern int diffcore_count_changes(void *src, unsigned long src_size,
107-
void *dst, unsigned long dst_size,
106+
extern int diffcore_count_changes(struct diff_filespec *src,
107+
struct diff_filespec *dst,
108108
void **src_count_p,
109109
void **dst_count_p,
110110
unsigned long delta_limit,

0 commit comments

Comments
 (0)