Re: [PATCH] rev-list: estimate number of bisection step left
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Feb 17, 2009, 15:39 UTC
- Message-ID
- <alpine.DEB.1.00.0902171639060.6185@intel-tinevez-2-302>
- In-Reply-To
- <43d8ce650902170736h6316f987qc783edeebf488b40@mail.gmail.com>
Hi,
On Tue, 17 Feb 2009, John Tapsell wrote:
Show 47 quoted lines
> 2009/2/17 Johannes Schindelin <Johannes.Schindelin@gmx.de>:
>
> > On Tue, 17 Feb 2009, John Tapsell wrote:
> >
> >> 2009/2/17 Johannes Schindelin <Johannes.Schindelin@gmx.de>:
> >>
> >> > On Tue, 17 Feb 2009, Christian Couder wrote:
> >> >
> >> >> +static int estimate_bisect_steps(int all)
> >> >> +{
> >> >> + int log2 = 0;
> >> >> + int left = (all >> 1) - 1;
> >> >> +
> >> >> + if (left <= 0)
> >> >> + return 0;
> >> >> +
> >> >> + do {
> >> >> + left = left >> 1;
> >> >> + log2++;
> >> >> + } while (left);
> >> >> +
> >> >> + return log2;
> >> >> +}
> >> >
> >> > How about this instead, calling it from cmd_rev_list directly?
> >> >
> >> > static int log2(int n)
> >> > {
> >> > int log2;
> >> >
> >> > for (log2 = 0; n > 1; log2++)
> >> > n >>= 1;
> >> >
> >> > return log2;
> >> > }
> >>
> >> This would work, if you want a non-iterative solution
> >>
> >> unsigned int log2_integer_approximate(unsigned int n){
> >> *((float*)&n) = (float)n;
> >> return ((n & (~((1<<23) - 1))) >> 23) - 127;
> >> }
> >
> > That assumes that your floats are IEEE floats, right?
>
> Yeah. Is it a bad assumption? Does git run on any system in which they
> aren't?Only when you are porting Git to embedded devices.
Don't moan: there exists a git-daemon for iPhone. Oh, wait! /me scribbles that down for the UGFWIINI contest.
Ciao, Dscho