On Mon, Feb 4, 2013 at 3:58 PM, Andrii Melnykov <andy.melni...@gmail.com>wrote:
> http://hpaste.org/81784 contains a benchmark - slow_test() is twice as > slow as fast_test() [...] > The way Array.prototype.map is specified (see section 15.4.4.19 in the ECMA spec) makes it very hard to implement efficiently. One has to create a new array for the result and has to be prepared for the case when the callback function modifies the array. Furthermore, we don't do any deforestation, which is "a bit" hard in JavaScript. Therefore, fast_test() basically does something different than slow_test(): It is optimized knowing the fact that the callback function does not modify the underlying array + it does the deforestation by hand, avoiding the need for an intermediate array. In a nutshell: It shouldn't be a surprise that fast_test() is, well, faster than slow_test()... -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.