TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Arguments Object: Doctor Jekyll and Mister Hyde in Node.js

37 pointsby chapelalmost 14 years ago

4 comments

willwagneralmost 14 years ago
Just to highlight what for me was non-obvious but interesting. It implies that this change in two places made a significant improvement to their performance stats. Basically, the optimizing compiler is finicky about the arguments object especially if it is used out of bounds. Without that knowledge, the change seems non-intuitive. I wonder if this true for all pseudo-arrays?<p>Old Code:<p><pre><code> var args = Array.prototype.slice.call(arguments, 1); </code></pre> New Code:<p><pre><code> var l = arguments.length; var args = new Array(l - 1); for (var i = 1; i &#60; l; i++) args[i - 1] = arguments[i];</code></pre>
评论 #2771141 未加载
评论 #2771183 未加载
评论 #2771701 未加载
blinkingledalmost 14 years ago
Funny how the commit for this change had no accompanying comment - this particular change begs for a clear comment!<p><a href="https://github.com/joyent/node/commit/91f1b250ecb4fb8151cd17423dd4460652d0ce97" rel="nofollow">https://github.com/joyent/node/commit/91f1b250ecb4fb8151cd17...</a>
评论 #2771801 未加载
yonranalmost 14 years ago
Does this mean that passing the arguments object to any function (even Array.prototype.slice) will ruin your performance? This is extremely common in many libraries' bind/partial functions e.g. Underscore, Closure, var_args in Coffeescript.
评论 #2771144 未加载
bauchidgwalmost 14 years ago
hmmm... anybody knows if this is an issue for coffeescript generated javascript, too?
评论 #2771219 未加载
评论 #2771056 未加载