Hacker News new | ask | show | jobs
by mlubin 4652 days ago
That's a good tip in general, but it's mostly aimed at addressing type instability. For example, if you have

   x = 1
   f(x)
   x = "foobar"
   f(x)
then each call to f will be optimized for the current type of x. On the other hand, if your code is type stable, as it appears to be here, it will be properly optimized in place by the Julia JIT compiler and there's no need split it into separate functions.