summaryrefslogtreecommitdiff
path: root/file
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-29 02:27:09 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-08-29 02:27:09 (GMT)
commit4f60abb2d01037f98e00ee365026e7d1b720fe35 (patch)
tree3ef9a18db785f8315baa7168099bc0e5ea277d2a /file
parentd05810c8d4c88eb73cb0350df1ab5c896c04c3c4 (diff)
downloadeeshow-4f60abb2d01037f98e00ee365026e7d1b720fe35.zip
eeshow-4f60abb2d01037f98e00ee365026e7d1b720fe35.tar.gz
eeshow-4f60abb2d01037f98e00ee365026e7d1b720fe35.tar.bz2
file/git-hist.c (hist_iterate): pass "next" pointer as well
This way, the callback don't need to search the list to figure it out on its own.
Diffstat (limited to 'file')
-rw-r--r--file/git-hist.c18
-rw-r--r--file/git-hist.h3
2 files changed, 9 insertions, 12 deletions
diff --git a/file/git-hist.c b/file/git-hist.c
index 7fa3c81..b536c22 100644
--- a/file/git-hist.c
+++ b/file/git-hist.c
@@ -642,7 +642,8 @@ enum thread *threads_classify(const struct vcs_history *history,
void hist_iterate(struct vcs_history *history,
- void (*fn)(void *user, struct vcs_hist *h), void *user)
+ void (*fn)(void *user, struct vcs_hist *h, const struct vcs_hist *next),
+ void *user)
{
unsigned i;
@@ -651,7 +652,9 @@ void hist_iterate(struct vcs_history *history,
history->max_threads = assign_threads(history);
}
for (i = 0; i != history->n_hist; i++)
- fn(user, history->sorted_hist[i]);
+ fn(user, history->sorted_hist[i],
+ i + 1 == history->n_hist ?
+ NULL : history->sorted_hist[i + 1]);
}
@@ -664,23 +667,16 @@ void hist_iterate(struct vcs_history *history,
// http://stackoverflow.com/questions/12132862/how-do-i-get-the-name-of-the-current-branch-in-libgit2
-static void dump_one(void *user, struct vcs_hist *h)
+static void dump_one(void *user, struct vcs_hist *h,
+ const struct vcs_hist *next)
{
struct vcs_history *history = user;
git_buf buf = { 0 };
enum thread *t;
unsigned n = threads_number(history);
unsigned i, j;
- const struct vcs_hist *next;
bool before, here, after;
- next = NULL;
- if (history->n_hist)
- for (i = 0; i != history->n_hist - 1; i++)
- if (history->sorted_hist[i] == h) {
- next = history->sorted_hist[i + 1];
- break;
- }
#ifdef DEBUG
fprintf(stderr, "%p (%u/%u):", h, h->n_newer, h->n_older);
for (i = 0; i != h->n_threads; i++)
diff --git a/file/git-hist.h b/file/git-hist.h
index d93907b..c5b7045 100644
--- a/file/git-hist.h
+++ b/file/git-hist.h
@@ -67,7 +67,8 @@ enum thread *threads_classify(const struct vcs_history *history,
const struct vcs_hist *h, const struct vcs_hist *next);
void hist_iterate(struct vcs_history *history,
- void (*fn)(void *user, struct vcs_hist *h), void *user);
+ void (*fn)(void *user, struct vcs_hist *h, const struct vcs_hist *next),
+ void *user);
void dump_hist(struct vcs_history *history);
#endif /* !FILE_GIT_HIST_H */