libbb: move isqrt from factor, use it in diff too

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2017-04-11 07:34:56 +02:00
parent 10673c44f1
commit 8a134ec680
4 changed files with 63 additions and 29 deletions

View File

@@ -295,17 +295,6 @@ static int search(const int *c, int k, int y, const struct cand *list)
}
}
static unsigned isqrt(unsigned n)
{
unsigned x = 1;
while (1) {
const unsigned y = x;
x = ((n / x) + x) >> 1;
if (x <= (y + 1) && x >= (y - 1))
return x;
}
}
static void stone(const int *a, int n, const int *b, int *J, int pref)
{
const unsigned isq = isqrt(n);