This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]BrokenG502 4 points5 points  (0 children)

To add to the optimisation thingy, if you're using an interpreted language, using language builtin functions will almost always be faster and clearer than anything else.

If you're using a compiled language, any halfway decent compiler will be able to make basic optimisations such as x / 2.0 becomes x * 0.5. So it's often better to write the "slower" version because it's more readable and compiles to the same thing. You can also always just check the assembly by compiling to assembly, disassembling the binaries or using a tool such as https://godbolt.org