Thread (7 messages) flat view 7 messages, 4 authors, 2016-06-15

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

From: John Tapsell <hidden>
Date: 2016-06-15 22:46:13

2009/2/17 Johannes Schindelin [off-list ref]:
Hi,

On Tue, 17 Feb 2009, Christian Couder wrote:
quoted
+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.)

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help