TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

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

37 点作者 chapel将近 14 年前

4 条评论

willwagner将近 14 年前
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 未加载
blinkingled将近 14 年前
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 未加载
yonran将近 14 年前
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 未加载
bauchidgw将近 14 年前
hmmm... anybody knows if this is an issue for coffeescript generated javascript, too?
评论 #2771219 未加载
评论 #2771056 未加载