Does V8 optimize multiple function calls that are the same function and arguments? In the example below Variance is called twice with the same arguments.
var Variance = require('variance');
function summary(items) {
return {
variance: Variance(items.value.map((item) => item.value)),
standardDeviation: Math.sqrt(Variance(items.value.map((item) => item.value))),
};
}
v8确实优化了使用相同参数重复调用的函数,但是在您的示例中,它们实际上不是相同的参数(它们是不同的对象/数组引用)。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.