[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Can someone sell Lua 5.2.0 to me please ?
- From: Mark Hamburg <mark@...>
- Date: Wed, 21 Dec 2011 08:30:10 -0800
Indeed Amdahl's law effectively tells us that it's fine to be inefficient in small portions of the code if they aren't hit too often.
However, the problem with encouraging people to generate tables of functions which will then immediately get thrown away in order to handle case dispatching is that once one gets in the habit, this sort of code can also slip into more performance critical portions of the code. This is particularly true on a project with a larger team where some team members may not be as attuned to the performance trade offs in particular constructs.
Should one optimize each piece of code as if it's critical? No. See all the warnings about premature optimization. But being in the habit of writing code that is basically efficient while still clear is a good habit that can prevent the need to go hunting down performance problems.
As for whether a select/case statement is enough clearer than a series of if/elseif/elseif/.../end statements is a different argument.
On Dec 21, 2011, at 7:38 AM, Alexander Gladysh wrote:
> If a piece code takes only 0.1% of execution time, you wouldn't speed
> up your program more by 0.1% no matter that you do with it.
> Do you really have that many if-elseif blocks so that matters?