New issue 4 by mikesamuel: Unnecessary object creation in jseval
http://code.google.com/p/google-jstemplate/issues/detail?id=4
util.js has the following comment
// NOTE(mesch): An alternative idiom would be:
//
// eval('(' + expr + ')');
//
// Note that using the square brackets as below, "" evals to undefined.
// The alternative of using parentheses does not work when evaluating
// function literals in IE.
// e.g. eval("(function() {})") returns undefined, and not a function
// object, in IE.
This is correct, but the solution:
return eval('[' + expr + '][0]');
creates an immediately discarded array object even on interpreters that do
not have IE's bug.
An alternative which creates fewer objects is:
return eval('0,(' + expr + ')');
Moving the strings '0,(', and ')' out of the function body will create
fewer string objects too.
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings