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 <gitster@pobox.com>
This commit is contained in:
@ -66,8 +66,7 @@ static int should_break(struct diff_filespec *src,
|
|||||||
if (base_size < MINIMUM_BREAK_SIZE)
|
if (base_size < MINIMUM_BREAK_SIZE)
|
||||||
return 0; /* we do not break too small filepair */
|
return 0; /* we do not break too small filepair */
|
||||||
|
|
||||||
if (diffcore_count_changes(src->data, src->size,
|
if (diffcore_count_changes(src, dst,
|
||||||
dst->data, dst->size,
|
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
0,
|
0,
|
||||||
&src_copied, &literal_added))
|
&src_copied, &literal_added))
|
||||||
|
@ -156,8 +156,8 @@ static struct spanhash_top *hash_chars(unsigned char *buf, unsigned int sz)
|
|||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
int diffcore_count_changes(void *src, unsigned long src_size,
|
int diffcore_count_changes(struct diff_filespec *src,
|
||||||
void *dst, unsigned long dst_size,
|
struct diff_filespec *dst,
|
||||||
void **src_count_p,
|
void **src_count_p,
|
||||||
void **dst_count_p,
|
void **dst_count_p,
|
||||||
unsigned long delta_limit,
|
unsigned long delta_limit,
|
||||||
@ -172,14 +172,14 @@ int diffcore_count_changes(void *src, unsigned long src_size,
|
|||||||
if (src_count_p)
|
if (src_count_p)
|
||||||
src_count = *src_count_p;
|
src_count = *src_count_p;
|
||||||
if (!src_count) {
|
if (!src_count) {
|
||||||
src_count = hash_chars(src, src_size);
|
src_count = hash_chars(src->data, src->size);
|
||||||
if (src_count_p)
|
if (src_count_p)
|
||||||
*src_count_p = src_count;
|
*src_count_p = src_count;
|
||||||
}
|
}
|
||||||
if (dst_count_p)
|
if (dst_count_p)
|
||||||
dst_count = *dst_count_p;
|
dst_count = *dst_count_p;
|
||||||
if (!dst_count) {
|
if (!dst_count) {
|
||||||
dst_count = hash_chars(dst, dst_size);
|
dst_count = hash_chars(dst->data, dst->size);
|
||||||
if (dst_count_p)
|
if (dst_count_p)
|
||||||
*dst_count_p = dst_count;
|
*dst_count_p = dst_count;
|
||||||
}
|
}
|
||||||
|
@ -189,8 +189,7 @@ static int estimate_similarity(struct diff_filespec *src,
|
|||||||
|
|
||||||
delta_limit = (unsigned long)
|
delta_limit = (unsigned long)
|
||||||
(base_size * (MAX_SCORE-minimum_score) / MAX_SCORE);
|
(base_size * (MAX_SCORE-minimum_score) / MAX_SCORE);
|
||||||
if (diffcore_count_changes(src->data, src->size,
|
if (diffcore_count_changes(src, dst,
|
||||||
dst->data, dst->size,
|
|
||||||
&src->cnt_data, &dst->cnt_data,
|
&src->cnt_data, &dst->cnt_data,
|
||||||
delta_limit,
|
delta_limit,
|
||||||
&src_copied, &literal_added))
|
&src_copied, &literal_added))
|
||||||
|
@ -103,8 +103,8 @@ void diff_debug_queue(const char *, struct diff_queue_struct *);
|
|||||||
#define diff_debug_queue(a,b) do {} while(0)
|
#define diff_debug_queue(a,b) do {} while(0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern int diffcore_count_changes(void *src, unsigned long src_size,
|
extern int diffcore_count_changes(struct diff_filespec *src,
|
||||||
void *dst, unsigned long dst_size,
|
struct diff_filespec *dst,
|
||||||
void **src_count_p,
|
void **src_count_p,
|
||||||
void **dst_count_p,
|
void **dst_count_p,
|
||||||
unsigned long delta_limit,
|
unsigned long delta_limit,
|
||||||
|
Reference in New Issue
Block a user