Titanium JIRA Archive
Alloy (ALOY)

[ALOY-1266] Use indirect eval instead of direct eval

GitHub Issuen/a
TypeImprovement
PriorityNone
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsRuntime, Styling
Labelsn/a
ReporterFokke Zandbergen
AssigneeBruce Wayne
Created2015-05-13T09:00:49.000+0000
Updated2015-05-21T06:30:18.000+0000

Description

As pointed out by many resources, including [Effective JavaScript](https://books.google.nl/books?id=nBuA0hmspdMC&lpg=PA55&ots=X1KF5B5wRE&dq=javascript%20indirect%20vs%20direct%20eval%20performance&hl=nl&pg=PA54#v=onepage&q=javascript%20indirect%20vs%20direct%20eval%20performance&f=false) it is better to use eval() in [indirect mode](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval#Description). For $.UI.create we are [currently using](https://github.com/appcelerator/alloy/blob/2ed8dc1da24cea4e97aa7ba82d3fd628e22fc820/Alloy/lib/alloy.js#L230) direct eval(), which can easily be made indirect by replace eval with (0,eval). PR on master: https://github.com/appcelerator/alloy/pull/686

Comments

  1. Fokke Zandbergen 2015-05-21

    Benchmark shows that direct is fastest, so we should only do this if we agree it's a best practice. https://gist.github.com/FokkeZB/1cdda90c657d9bf4fb28#file-results-md

JSON Source