> On May 12, 2016, at 9:39 AM, Brian Barnes <gga...@charter.net> wrote: > > ... > If I call doSomething a lot of times, I get a lot of objects to be tracked > and GC’d. Yes, I can rewrite that code to obviously eliminate them, but > pretend there is actually something interesting happening here that requires > those variables. And engines can be smart enough to mark them and deal with > them with the function ends (I don’t know if this is done.) > > What I’m thinking is some kind of class based hint that would “super” hoist > all local function variables. It would be sugar but it would transform it > into: >
Local variables like a,b,c in your example are probably the least expensive construct in JS. In your example, there are no objects created by doSomething, not state that persists after doSomething returns, and no GC pressure. Anything you do WRT moving such local state into object properties is going to be more expensive. Allen _______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss