Skip to content

Commit 739864b

Browse files
rctaygitster
authored andcommitted
xdiff: do away with xdl_mmfile_next()
Given our simple mmfile structure, xdl_mmfile_next() calls are redundant. Do away with calls to them. Signed-off-by: Tay Ray Chuan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 286e2b1 commit 739864b

File tree

3 files changed

+2
-20
lines changed

3 files changed

+2
-20
lines changed

xdiff/xdiff.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ typedef struct s_bdiffparam {
106106
#define xdl_realloc(ptr,x) realloc(ptr,x)
107107

108108
void *xdl_mmfile_first(mmfile_t *mmf, long *size);
109-
void *xdl_mmfile_next(mmfile_t *mmf, long *size);
110109
long xdl_mmfile_size(mmfile_t *mmf);
111110

112111
int xdl_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,

xdiff/xprepare.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,7 @@ static int xdl_prepare_ctx(mmfile_t *mf, long narec, xpparam_t const *xpp,
168168

169169
nrec = 0;
170170
if ((cur = blk = xdl_mmfile_first(mf, &bsize)) != NULL) {
171-
for (top = blk + bsize;;) {
172-
if (cur >= top) {
173-
if (!(cur = blk = xdl_mmfile_next(mf, &bsize)))
174-
break;
175-
top = blk + bsize;
176-
}
171+
for (top = blk + bsize; cur < top; ) {
177172
prev = cur;
178173
hav = xdl_hash_record(&cur, top, xpp->flags);
179174
if (nrec >= narec) {

xdiff/xutils.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,6 @@ void *xdl_mmfile_first(mmfile_t *mmf, long *size)
6767
}
6868

6969

70-
void *xdl_mmfile_next(mmfile_t *mmf, long *size)
71-
{
72-
return NULL;
73-
}
74-
75-
7670
long xdl_mmfile_size(mmfile_t *mmf)
7771
{
7872
return mmf->size;
@@ -160,13 +154,7 @@ long xdl_guess_lines(mmfile_t *mf, long sample) {
160154
char const *data, *cur, *top;
161155

162156
if ((cur = data = xdl_mmfile_first(mf, &size)) != NULL) {
163-
for (top = data + size; nl < sample;) {
164-
if (cur >= top) {
165-
tsize += (long) (cur - data);
166-
if (!(cur = data = xdl_mmfile_next(mf, &size)))
167-
break;
168-
top = data + size;
169-
}
157+
for (top = data + size; nl < sample && cur < top; ) {
170158
nl++;
171159
if (!(cur = memchr(cur, '\n', top - cur)))
172160
cur = top;

0 commit comments

Comments
 (0)