FrederikTheisen a écrit:I know that the code is not optimized (not checking double will be a nice fix for sure).
See his edit above.
A note about that : in general, memoization (yes that's the right word) is a good idea.
(Edit : well, I mean, rather about "caching" results instead of re-calculating stuff several times - if you can't do it otherwise, of course)
FrederikTheisen a écrit:Though many o the constants are declared (as local) outside the code snippet i shared (program is currently 700 lines + 8000 lines database)
Using locals instead of globals whenever you can is better, in short.
Also valid with functions from modules like math etc. : when you use them (especially a lot, like in loops, localize them before, it'll be faster in the loop. See above code with sqrt)
FrederikTheisen a écrit:I'm not familiar with the coroutine 'function', but I hope that it will address the problem.
That sure is advanced Lua and will likely be confusing for you if you're only beginning - but don't worry, it's not that scary
For more optimization tricks : archives_voir.php?id=6720
(and there is another one more recent but I can't access it because the host (free.fr) recently changed its policy on listing the content of ftp directory... meh)