Re: [PATCH 15/16] commit-reach: make can_all_from_reach... linear

2018-10-17 Thread Jeff King
On Sun, Oct 14, 2018 at 04:29:06PM +0200, René Scharfe wrote: > Anyway, drove the generative approach a bit further, and came up with > the new DEFINE_SORT below. I'm unsure about the name; perhaps it should > be called DEFINE_SORT_BY_COMPARE_FUNCTION_BODY, but that's a bit long. > It handles

Re: [PATCH 15/16] commit-reach: make can_all_from_reach... linear

2018-10-16 Thread Junio C Hamano
René Scharfe writes: > Apart from that the macro is simple and doesn't use any tricks or > added checks. It just sets up boilerplate functions to offer type-safe > sorting. > ... > diff --git a/git-compat-util.h b/git-compat-util.h > index 5f2e90932f..491230fc57 100644 > --- a/git-compat-util.h

Re: [PATCH 15/16] commit-reach: make can_all_from_reach... linear

2018-10-15 Thread René Scharfe
Am 15.10.2018 um 17:31 schrieb Derrick Stolee: > On 10/14/2018 10:29 AM, René Scharfe wrote: >> diff --git a/git-compat-util.h b/git-compat-util.h >> index 5f2e90932f..491230fc57 100644 >> --- a/git-compat-util.h >> +++ b/git-compat-util.h >> @@ -1066,6 +1066,21 @@ static inline void

Re: [PATCH 15/16] commit-reach: make can_all_from_reach... linear

2018-10-15 Thread Derrick Stolee
On 10/14/2018 10:29 AM, René Scharfe wrote: It still has some repetition, converted code is a bit longer than the current one, and I don't know how to build a Coccinelle rule that would do that conversion. Looked for a possibility to at least leave QSORT call-sites alone by enhancing that

Re: [PATCH 15/16] commit-reach: make can_all_from_reach... linear

2018-10-14 Thread René Scharfe
Am 05.10.2018 um 21:42 schrieb Jeff King: > On Fri, Oct 05, 2018 at 09:36:28PM +0200, René Scharfe wrote: > >> Am 05.10.2018 um 21:08 schrieb Jeff King: >>> On Fri, Oct 05, 2018 at 08:48:27PM +0200, René Scharfe wrote: +#define DEFINE_SORT(name, type, compare) \

Re: [PATCH 15/16] commit-reach: make can_all_from_reach... linear

2018-10-05 Thread Jeff King
On Fri, Oct 05, 2018 at 09:42:49PM +0200, Ævar Arnfjörð Bjarmason wrote: > > that I imagine will create a lot of new problems. (We're just now > > allowing C99 -- I don't even want to think about what kind of compiler > > issues we'll run into on antique systems trying to use C++). > > ...But

Re: [PATCH 15/16] commit-reach: make can_all_from_reach... linear

2018-10-05 Thread Ævar Arnfjörð Bjarmason
On Fri, Oct 05 2018, Jeff King wrote: > On Fri, Oct 05, 2018 at 09:12:09PM +0200, Ævar Arnfjörð Bjarmason wrote: > >> > I'm not wild about declaring functions inside macros, just because it >> > makes tools like ctags like useful (but I have certainly been guilty of >> > it myself). I'd also

Re: [PATCH 15/16] commit-reach: make can_all_from_reach... linear

2018-10-05 Thread Jeff King
On Fri, Oct 05, 2018 at 09:36:28PM +0200, René Scharfe wrote: > Am 05.10.2018 um 21:08 schrieb Jeff King: > > On Fri, Oct 05, 2018 at 08:48:27PM +0200, René Scharfe wrote: > >> +#define DEFINE_SORT(name, type, compare) \ > >> +static int compare##_void(const void *one,

Re: [PATCH 15/16] commit-reach: make can_all_from_reach... linear

2018-10-05 Thread René Scharfe
Am 05.10.2018 um 21:08 schrieb Jeff King: > On Fri, Oct 05, 2018 at 08:48:27PM +0200, René Scharfe wrote: >> +#define DEFINE_SORT(name, type, compare)\ >> +static int compare##_void(const void *one, const void *two) \ >> +{

Re: [PATCH 15/16] commit-reach: make can_all_from_reach... linear

2018-10-05 Thread Jeff King
On Fri, Oct 05, 2018 at 09:12:09PM +0200, Ævar Arnfjörð Bjarmason wrote: > > I'm not wild about declaring functions inside macros, just because it > > makes tools like ctags like useful (but I have certainly been guilty of > > it myself). I'd also worry that taking "code" as a macro parameter

Re: [PATCH 15/16] commit-reach: make can_all_from_reach... linear

2018-10-05 Thread Ævar Arnfjörð Bjarmason
On Fri, Oct 05 2018, Jeff King wrote: > On Fri, Oct 05, 2018 at 12:59:02AM +0200, René Scharfe wrote: > >> We could also do something like this to reduce the amount of manual >> casting, but do we want to? (Macro at the bottom, three semi-random >> examples at the top.) >> [...] >> diff --git

Re: [PATCH 15/16] commit-reach: make can_all_from_reach... linear

2018-10-05 Thread Jeff King
On Fri, Oct 05, 2018 at 08:48:27PM +0200, René Scharfe wrote: > If the comparison function has proper types then we need to declare a > version with void pointer parameters as well to give to qsort(3). I > think using cast function pointers is undefined. Perhaps like this? I think it's

Re: [PATCH 15/16] commit-reach: make can_all_from_reach... linear

2018-10-05 Thread René Scharfe
Am 05.10.2018 um 18:51 schrieb Jeff King: > On Fri, Oct 05, 2018 at 12:59:02AM +0200, René Scharfe wrote: > >> We could also do something like this to reduce the amount of manual >> casting, but do we want to? (Macro at the bottom, three semi-random >> examples at the top.) >> [...] >> diff

Re: [PATCH 15/16] commit-reach: make can_all_from_reach... linear

2018-10-05 Thread Jeff King
On Fri, Oct 05, 2018 at 12:59:02AM +0200, René Scharfe wrote: > We could also do something like this to reduce the amount of manual > casting, but do we want to? (Macro at the bottom, three semi-random > examples at the top.) > [...] > diff --git a/git-compat-util.h b/git-compat-util.h > index

Re: [PATCH 15/16] commit-reach: make can_all_from_reach... linear

2018-10-05 Thread Derrick Stolee
On 10/4/2018 6:59 PM, René Scharfe wrote: Am 01.10.2018 um 22:37 schrieb René Scharfe: Am 01.10.2018 um 21:26 schrieb Derrick Stolee: Good catch! I'm disappointed that we couldn't use type-checking here, as it is quite difficult to discover that the types are wrong here. Generics in C are

Re: [PATCH 15/16] commit-reach: make can_all_from_reach... linear

2018-10-04 Thread René Scharfe
Am 01.10.2018 um 22:37 schrieb René Scharfe: > Am 01.10.2018 um 21:26 schrieb Derrick Stolee: >> On 10/1/2018 3:16 PM, René Scharfe wrote: >>> Am 28.06.2018 um 14:31 schrieb Derrick Stolee via GitGitGadget: diff --git a/commit-reach.c b/commit-reach.c index c58e50fbb..ac132c8e4 100644

Re: [PATCH 15/16] commit-reach: make can_all_from_reach... linear

2018-10-01 Thread René Scharfe
Am 01.10.2018 um 21:26 schrieb Derrick Stolee: > On 10/1/2018 3:16 PM, René Scharfe wrote: >> Am 28.06.2018 um 14:31 schrieb Derrick Stolee via GitGitGadget: >>> diff --git a/commit-reach.c b/commit-reach.c >>> index c58e50fbb..ac132c8e4 100644 >>> --- a/commit-reach.c >>> +++ b/commit-reach.c >>>

Re: [PATCH 15/16] commit-reach: make can_all_from_reach... linear

2018-10-01 Thread Derrick Stolee
On 10/1/2018 3:16 PM, René Scharfe wrote: Am 28.06.2018 um 14:31 schrieb Derrick Stolee via GitGitGadget: diff --git a/commit-reach.c b/commit-reach.c index c58e50fbb..ac132c8e4 100644 --- a/commit-reach.c +++ b/commit-reach.c @@ -513,65 +513,88 @@ int commit_contains(struct ref_filter *filter,

Re: [PATCH 15/16] commit-reach: make can_all_from_reach... linear

2018-10-01 Thread René Scharfe
Am 28.06.2018 um 14:31 schrieb Derrick Stolee via GitGitGadget: > diff --git a/commit-reach.c b/commit-reach.c > index c58e50fbb..ac132c8e4 100644 > --- a/commit-reach.c > +++ b/commit-reach.c > @@ -513,65 +513,88 @@ int commit_contains(struct ref_filter *filter, struct > commit *commit, >

Re: [PATCH 15/16] commit-reach: make can_all_from_reach... linear

2018-07-16 Thread Jonathan Tan
> The first step includes using a depth-first-search (DFS) from each from > commit, sorted by ascending generation number. We do not walk beyond the > minimum generation number or the minimum commit date. This DFS is likely > to be faster than the existing reachable() method because we expect >

Re: [PATCH 15/16] commit-reach: make can_all_from_reach... linear

2018-07-16 Thread Stefan Beller
On Mon, Jul 16, 2018 at 6:00 AM Derrick Stolee via GitGitGadget wrote: > > Note how the time increases between the two cases in the two versions. > The new code increases relative to the number of commits that need to be > walked, but not directly relative to the number of 'from' commits. Cool!

[PATCH 15/16] commit-reach: make can_all_from_reach... linear

2018-07-16 Thread Derrick Stolee via GitGitGadget
From: Derrick Stolee The can_all_from_reach_with_flags() algorithm is currently quadratic in the worst case, because it calls the reachable() method for every 'from' without tracking which commits have already been walked or which can already reach a commit in 'to'. Rewrite the algorithm to