Download raw body.
tog: keymaps to navigate to prev/next file/hunk in the diff
On Sun, Jul 31, 2022 at 10:19:22PM +1000, Mark Jamsek wrote: > +static void > +diff_prev_index(struct tog_diff_view_state *s, enum got_diff_line_type type) > +{ > + int i = s->first_displayed_line - 1; > + > + while (s->lines[i].type != type) { > + if (i == 0) > + i = s->nlines - 1; > + --i; > + } > + > + s->selected_line = 1; > + s->first_displayed_line = i; > +} > + > +static void > +diff_next_index(struct tog_diff_view_state *s, enum got_diff_line_type type) > +{ > + int i = s->first_displayed_line + 1; > + > + while (s->lines[i].type != type) { > + if (i == s->nlines - 1) > + i = 0; > + ++i; > + } > + > + s->selected_line = 1; > + s->first_displayed_line = i; > +} The above two functions assume that the request 'type' will always exist somewhere in the file. It looks like they would loop infinitely otherwise. Could this condition be detected and raised as an error, for robustness? That is the only potential issue I could spot during an initial read-through. All this is looking very nice overall! I will test it soon. > ----------------------------------------------- > commit 97249a619ed52d94faed9ac1e48448bd8cfd50bc (dev/dlines) > from: Mark Jamsek <mark@jamsek.dev> > date: Sun Jul 31 12:13:46 2022 UTC > > ARRAY_LIST allocation optimisation (3x speedup on large diffs) ok stsp@ for this diff already. > diff fa40c6ac5abc8ce998ce2ab3f3defa0baa10f264 97249a619ed52d94faed9ac1e48448bd8cfd50bc > commit - fa40c6ac5abc8ce998ce2ab3f3defa0baa10f264 > commit + 97249a619ed52d94faed9ac1e48448bd8cfd50bc > blob - 112da0c2e234000d38b2dea5c3b1112fa045b7a0 > blob + 8b503d2f97ddd5ce74010697dc9c40b1e8a4b7af > --- lib/arraylist.h > +++ lib/arraylist.h > @@ -63,14 +63,18 @@ > (ARRAY_LIST).p = recallocarray((ARRAY_LIST).head, \ > (ARRAY_LIST).len, \ > (ARRAY_LIST).allocated + \ > - ((ARRAY_LIST).alloc_blocksize ? : 8), \ > + ((ARRAY_LIST).allocated ? \ > + (ARRAY_LIST).allocated / 2 : \ > + (ARRAY_LIST).alloc_blocksize ? : 8), \ > sizeof(*(ARRAY_LIST).head)); \ > if ((ARRAY_LIST).p == NULL) { \ > NEW_ITEM_P = NULL; \ > break; \ > } \ > (ARRAY_LIST).allocated += \ > - (ARRAY_LIST).alloc_blocksize ? : 8; \ > + (ARRAY_LIST).allocated ? \ > + (ARRAY_LIST).allocated / 2 : \ > + (ARRAY_LIST).alloc_blocksize ? : 8, \ > (ARRAY_LIST).head = (ARRAY_LIST).p; \
tog: keymaps to navigate to prev/next file/hunk in the diff