|
Posted by ^reaper^ on 07/11/05 07:26
While sipping absinthe, Richard Cornford heard a loud sucking noise coming
from alt.2600,alt.html, and hastily inscribed the following unintelligible
Sanskrit in <news:dasjkp$5fm$1$8300dec7@news.demon.co.uk>:
> Onideus Mad Hatter wrote:
> <snip>
>> I just got through rewriting teh code from this:
> <snip>
>> To this:
>>: var IE = document.all ? true : false;
> <snip>
>>: while (i <= 10);
>>
>> I could probably make it even more efficient if I used case
>> instead of do/while.
>
> You mean switch? That would not help, as you would still need a loop
> round the switch statement.
>
> <snip>
>> ...of course, if I did even half of that...boy it'd sorta
>> make teh code a lil hard to read, wouldn't it?
> <snip>
>
> Which is why whitespace removal and Identifier shortening is done with
> software after development/debugging. Though the identifier shortening
> cannot be done by machine when the eval function is used to execute code
> as the software cannot tell when the contents of a string literal are
> going to be executed and refer to an identifier.
>
> But if the code was going to be less readable it may as well be rendered
> more efficient in the process:-
/me looks at hatter's code:
http://www.spyderware.net/source/omh.js
/me looks at yore code:
http://www.spyderware.net/source/rich.js
Yep. Perfect example wrt why, less is not always better. (e.g., hatter's
code is self documenting). That, and the question of efficiency is
dependent upon what it's actually doing. Or put another way, in this case,
your solution would result in a marginal increase in performance, while
negatively impacting maintenance (e.g., layout mods). So teh tradeoffs lean
in hatter's direction.
--
"An optimist believes we live in the best of all possible worlds. A
pessimist is sure of it!" -- Unknown
[Back to original message]
|