javascript - Chrome 分析器上的 "Unsupported non-primitive compare"

标签 javascript google-chrome-devtools v8

我的应用程序遇到瓶颈,

Chrome 告诉问题是不支持的非原始比较,我不确定我是否理解它的含义。

这是问题的确切代码(参见第 6 行)

for (var key in this.gdata) {
  var rows = this.gdata[key];
  for (var i = 0; i < rows.length; i++) {
    if (i === 0) first[key] = rows[i];
    if (rows[i].date > dt) {
      curr[key] = i > 0 && rows[i - 1]; //   <----  problem is here
      next[key] = rows[i];
      break;
    }
  }
}

这是一个屏幕截图,以防万一:

enter image description here

在这里我们可以更详细地看到瓶颈:

enter image description here

这段代码有什么问题?

最佳答案

Crankshaft 无法对此进行优化,因为它必须将 rows[i-1] 转换为 bool 值,并且它不知道如何在不进行去优化的情况下执行此操作。也许这会更好?

curr[key] = i > 0 ?行[i-1]:假;

关于javascript - Chrome 分析器上的 "Unsupported non-primitive compare",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40681455/

相关文章:

javascript - 在 jquery 中向下滚动页面时显示 div

javascript - 将 JavaScript 对象添加到多个数组

javascript - Chrome 开发工具 : inspect element on item that is visible only if parent has mouse over

node.js - Google Cloud Services 中 f1 微型实例中 node.js 进程的进程内存限制?

linux - 为 optware 编译 Node 时出错 - libv8.a : could not read symbols: File in wrong format

node.js - 如何更改 Node.js 内存设置以允许非常大 (>100GB) 内存

javascript - 删除使用 jQuery 创建的元素

javascript - React js 中的 "Mounting"是什么?

google-chrome - 在 Chrome Devtools 中添加侧边栏 - 网络 Pane

google-chrome-devtools - Chrome DevTools - SQL 查询未执行