我有这种情况:
let scans = [
{ source: "10.0.0.2", destination: "20.0.0.2" }
{ source: "10.0.0.4", destination: "20.0.0.6" }
]
const handleScan = (source, destination, port) => {
let newScan = {
source : source,
destination : destination
}
for (scan of scans) {
if (scan.source !== source && scan.destination !== destination)
scans.push(newScan)
}
}
现在,该函数每秒执行 1000 次,这意味着每次查看该对是否存在的 for 循环非常糟糕。你会建议我如何更有效地做到这一点?
烙印99
相关分类