Skip to content

Commit

Permalink
xdiff: do away with xdl_mmfile_next()
Browse files Browse the repository at this point in the history
Given our simple mmfile structure, xdl_mmfile_next() calls are
redundant. Do away with calls to them.

Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Tay Ray Chuan authored and Junio C Hamano committed Aug 3, 2011
1 parent 286e2b1 commit 739864b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 20 deletions.
1 change: 0 additions & 1 deletion xdiff/xdiff.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ typedef struct s_bdiffparam {
#define xdl_realloc(ptr,x) realloc(ptr,x)

void *xdl_mmfile_first(mmfile_t *mmf, long *size);
void *xdl_mmfile_next(mmfile_t *mmf, long *size);
long xdl_mmfile_size(mmfile_t *mmf);

int xdl_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
Expand Down
7 changes: 1 addition & 6 deletions xdiff/xprepare.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,7 @@ static int xdl_prepare_ctx(mmfile_t *mf, long narec, xpparam_t const *xpp,

nrec = 0;
if ((cur = blk = xdl_mmfile_first(mf, &bsize)) != NULL) {
for (top = blk + bsize;;) {
if (cur >= top) {
if (!(cur = blk = xdl_mmfile_next(mf, &bsize)))
break;
top = blk + bsize;
}
for (top = blk + bsize; cur < top; ) {
prev = cur;
hav = xdl_hash_record(&cur, top, xpp->flags);
if (nrec >= narec) {
Expand Down
14 changes: 1 addition & 13 deletions xdiff/xutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,6 @@ void *xdl_mmfile_first(mmfile_t *mmf, long *size)
}


void *xdl_mmfile_next(mmfile_t *mmf, long *size)
{
return NULL;
}


long xdl_mmfile_size(mmfile_t *mmf)
{
return mmf->size;
Expand Down Expand Up @@ -160,13 +154,7 @@ long xdl_guess_lines(mmfile_t *mf, long sample) {
char const *data, *cur, *top;

if ((cur = data = xdl_mmfile_first(mf, &size)) != NULL) {
for (top = data + size; nl < sample;) {
if (cur >= top) {
tsize += (long) (cur - data);
if (!(cur = data = xdl_mmfile_next(mf, &size)))
break;
top = data + size;
}
for (top = data + size; nl < sample && cur < top; ) {
nl++;
if (!(cur = memchr(cur, '\n', top - cur)))
cur = top;
Expand Down

0 comments on commit 739864b

Please sign in to comment.