On Sun, Sep 18, 2011 at 6:19 AM, Brendan Eich <bren...@mozilla.com> wrote:
> > Who ever said they didn't? > Sam did: > You'd need a benchmark that shows that the object allocation you're > avoiding here is worth the lack of flexibility. I see what you are getting at now, but you're missing something: your test2 > has an object literal per loop iteration which cannot be optimized away > easily. The object and array literals in my slide that you are concerned > about: > > > - new Triangle([{ point: { x: 0, y: 0 }, > color: { r: 255, g: 255, b: 255 } }, > { point: { x: 5, y: 5 }, > color: { r: 128, g: 0, b: 0 } }, > { point: { x: 10, y: 0 }, > color: { r: 0, g: 0, b: 128 } }]); > > are neither mandatory -- see > http://wiki.ecmascript.org/doku.php?id=harmony:binary_data_semantics#array_objectsand > note how you can call new Triangle() and set members using dotted access > and assignment -- nor as hard to optimize away than in the general case. > So you are suggesting to do something like this: var p0 = new Point2D, p1 = new Point2D, p2 = new Point2D, c0 = new Color, c1 = new Color, c2 = new Color, px0 = new Pixel, px1 = new Pixel, px2 = new Pixel, t = new Triangle([px0, px1, px2]) and per each typed object assign properties ... p0.x = 0; p0.y = 0; ... sure this avoid creation of literal but who's gonna do that ? OK, at least it is possible. > > How did the performance change? > in my Mac 13ms VS 16ms surely more if I use the Atom based Netbook Best Regards, Andrea Giammarchi
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss