Hi folks,

while I was 'cleaning up' our code base I've come along the JSON class of
qooxdoo.
Is there any reason why it uses the evil eval() function for evaluating and
parsing the backend responses? Wouldn't "Function" be the better choice?

I've tried the following replacement in our application that works quite good
(and is about 6 to 7 times faster!):

Original version:
<code>
  parseQx : function (text)
  {
    ...
    var obj = (text && text.length > 0)
            ? eval('(' + text + ')')
            : null;
    ...
  }
</code>

Changed version:
<code>
  parseQx : function (text)
  {
    ...
    var obj = (text && text.length > 0)
            ? Function("return " + text + ";")()
            : null;
    ...
  }
</code>

Is there any reason why this might not work? Or is there a reason why eval() is
used in the first place?
I'm currently using qooxdoo from the lagacy_0_7_x SVN-branch but the same kind
of code also appears in the trunk.

Thank you for any further insight into this,

  Peter


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to