Skip to content

Commit

Permalink
Optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
tumic0 committed Oct 22, 2024
1 parent 5b5e000 commit 5a71ded
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/map/dem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,20 @@

static unsigned int isqrt(unsigned int x)
{
unsigned int r = 0;
unsigned int l = 0;
unsigned int m;
unsigned int r = x + 1;

while ((r + 1) * (r + 1) <= x)
r++;
while (l != r - 1) {
m = (l + r) / 2;

return r;
if (m * m <= x)
l = m;
else
r = m;
}

return l;
}

static double interpolate(double dx, double dy, double p0, double p1, double p2,
Expand Down

0 comments on commit 5a71ded

Please sign in to comment.