git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] rev-list: estimate number of bisection step left

From
John Tapsell <johnflux@gmail.com>
Date
Feb 17, 2009, 15:11 UTC
Message-ID
<43d8ce650902170711r1edb1e40udfacce4b9123b0a5@mail.gmail.com>
In-Reply-To
<alpine.DEB.1.00.0902171542490.6185@intel-tinevez-2-302>
2009/2/17 Johannes Schindelin <Johannes.Schindelin@gmx.de>:
Show 31 quoted lines
> Hi,
>
> 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; }

(It's correct up to 2^25, then it's off by 1 for a few.)
Show 7 quoted lines
> Ciao,
> Dscho
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 9 of 13 in “rev-list: estimate number of bisection step left”
  1. rev-list: estimate number of bisection step leftChristian Couder, Feb 17, 2009
  2. Junio C HamanoFeb 17, 2009
  3. Christian CouderFeb 19, 2009
  4. Christian CouderFeb 19, 2009
  5. Christian CouderFeb 19, 2009
  6. John TapsellFeb 19, 2009
  7. Christian CouderFeb 19, 2009
  8. Johannes SchindelinFeb 17, 2009
  9. John TapsellFeb 17, 2009
  10. Johannes SchindelinFeb 17, 2009
  11. John TapsellFeb 17, 2009
  12. Johannes SchindelinFeb 17, 2009
  13. Thomas RastFeb 17, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.