On Wed, Feb 8, 2017 at 10:29 AM, Alex Goldsmith
<[email protected]> wrote:
> Howdy.
>
> I was just reading through the Optimization Killers article on the Bluebird
> wiki, trying to work out whether the following would be optimized:
>
> function get(/* ...k, j, i */) {
>    const a = arguments, l = a.length, n = l - 1
>    switch (l) {
>       case 0: return this
>       case 1: return this[a[n]]
>       default: return get.apply(this[a[a.length = n]], a) // a.length = n =
> a.length - 1
>    }
> }
>
> console.log(get.call({x:{y:{z:'!!!'}}}, 'z','y','x')) // => "!!!"
>
>
> Shedding an argument in this way isn't really discussed (anywhere that I can
> find), but it seems like it should be okay (at least it doesn't appear to be
> leaking).
>
> Any insight would be highly appreciated. Thanks in advance!

Start node or d8 with --trace_opt and it will tell you.  My bet is
that you'll see a "Bad value context for arguments value" warning; V8
really doesn't like it when you modify arguments objects.

-- 
-- 
v8-users mailing list
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to