faster representation of pow on some áreas of subsurface?

Tomaz Canabrava tcanabrava at
Sun Jan 19 11:29:22 UTC 2014


I noticed a little lag while switching dives on the new profile, thing that
I tougth it shouldn't exist because the new code of the profile tries real
hard to be very responsive, then I fired callgrind to find the guilty one:


and the biggest part of add_segment is the pow() function.

I'v replaced the pow() call with the fastPow() that I found on the internet
and it got *way* snappyer.

double fastPow(double a, double b) {
  union {
    double d;
    int x[2];
  } u = { a };
  u.x[1] = (int)(b * (u.x[1] - 1072632447) + 1072632447);
  u.x[0] = 0;
  return u.d;

I dunno how is this compared with the real pow in terms of correctness, but
it make the profile very responsive, even the old one.

I found the code ( with the documentation on how the magic numbers works )

can you low level guys take a look at it and see if it woths the change?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the subsurface mailing list