Skip to content

Commit

Permalink
Merge 'some-small-patches'
Browse files Browse the repository at this point in the history
This topic branch brings some small patches from the mailing list to
GVFS.

1. Preempt a `has_object_file()` call during
`mark_parents_uninteresting()` to speed up merge base calculations. I
measured a 7% improvement in `git status` on Linux without the graph and
a 27% improvement with the graph. See [the discussion on the mailing
list](https://public-inbox.org/git/20180226013822.GA9385@sigill.intra.peff.net/T/#t).

2. Fix an uninitialized memory issue in the abbreviation code for
packfiles; carry that over to the MIDX. See  [the discussion on the
mailing
list](https://public-inbox.org/git/0a85ea3b-3f64-f67d-b4d5-a761cbc4c6db@gmail.com/T/#t)
  • Loading branch information
derrickstolee authored and dscho committed Feb 26, 2018
2 parents 869d868 + 7cdbbf0 commit f17ab83
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
3 changes: 2 additions & 1 deletion revision.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ void mark_parents_uninteresting(struct commit *commit)
* it is popped next time around, we won't be trying
* to parse it and get an error.
*/
if (!has_object_file(&commit->object.oid))
if (!commit->object.parsed &&
!has_object_file(&commit->object.oid))
commit->object.parsed = 1;

if (commit->object.flags & UNINTERESTING)
Expand Down
24 changes: 8 additions & 16 deletions sha1_name.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,17 +557,14 @@ static void find_abbrev_len_for_midx(struct midxed_git *m,
* nearby for the abbreviation length.
*/
mad->init_len = 0;
if (!match) {
nth_midxed_object_oid(&oid, m, first);
if (!match && nth_midxed_object_oid(&oid, m, first))
extend_abbrev_len(&oid, mad);
} else if (first < m->num_objects - 1) {
nth_midxed_object_oid(&oid, m, first + 1);
else if (first < m->num_objects - 1 &&
nth_midxed_object_oid(&oid, m, first + 1))
extend_abbrev_len(&oid, mad);
}
if (first > 0) {
nth_midxed_object_oid(&oid, m, first - 1);
if (first > 0 && nth_midxed_object_oid(&oid, m, first - 1))
extend_abbrev_len(&oid, mad);
}

mad->init_len = mad->cur_len;
}

Expand Down Expand Up @@ -609,17 +606,12 @@ static void find_abbrev_len_for_pack(struct packed_git *p,
* nearby for the abbreviation length.
*/
mad->init_len = 0;
if (!match) {
nth_packed_object_oid(&oid, p, first);
if (!match && nth_packed_object_oid(&oid, p, first))
extend_abbrev_len(&oid, mad);
} else if (first < num - 1) {
nth_packed_object_oid(&oid, p, first + 1);
if (first < num - 1 && nth_packed_object_oid(&oid, p, first + 1))
extend_abbrev_len(&oid, mad);
}
if (first > 0) {
nth_packed_object_oid(&oid, p, first - 1);
if (first > 0 && nth_packed_object_oid(&oid, p, first - 1))
extend_abbrev_len(&oid, mad);
}
mad->init_len = mad->cur_len;
}

Expand Down

0 comments on commit f17ab83

Please sign in to comment.