Skip to content

Commit

Permalink
Merge pull request #996 from jeffhostetler/jeffhostetler/register_ren…
Browse files Browse the repository at this point in the history
…ame_src

diffcore-rename: speed up register_rename_src
  • Loading branch information
dscho committed Jan 25, 2017
2 parents ebe196a + 23da3cc commit a28f3d8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions diffcore-rename.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ static struct diff_rename_src *locate_rename_src(struct diff_filespec *one,

first = 0;
last = rename_src_nr;

if (last > 0) {
struct diff_rename_src *src = &(rename_src[last-1]);
int cmp = strcmp(one->path, src->p->one->path);
if (!cmp)
return src;
if (cmp > 0) {
first = last;
goto append_it;
}
}

while (last > first) {
int next = (last + first) >> 1;
struct diff_rename_src *src = &(rename_src[next]);
Expand All @@ -93,6 +105,7 @@ static struct diff_rename_src *locate_rename_src(struct diff_filespec *one,
first = next+1;
}

append_it:
if (!insert_ok)
return NULL;

Expand Down

0 comments on commit a28f3d8

Please sign in to comment.