1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-11 01:42:22 +03:00

Use the __builtin_clzll() function of gcc to improve the performance and

reduce the size of the sqlite3LogEst() routine.

FossilOrigin-Name: a42a438cbbd721765ca55e71c464552dbaa494050cf472593599b8c7f0249516
This commit is contained in:
drh
2017-08-17 20:53:07 +00:00
parent dceed86d07
commit ceb4b1dbdd
3 changed files with 13 additions and 7 deletions

View File

@@ -1413,8 +1413,14 @@ LogEst sqlite3LogEst(u64 x){
if( x<2 ) return 0;
while( x<8 ){ y -= 10; x <<= 1; }
}else{
#if GCC_VERSION>=5004000
int i = 60 - __builtin_clzll(x);
y += i*10;
x >>= i;
#else
while( x>255 ){ y += 40; x >>= 4; } /*OPTIMIZATION-IF-TRUE*/
while( x>15 ){ y += 10; x >>= 1; }
#endif
}
return a[x&7] + y - 10;
}