Optimize PathSet for V8

PathSet.find has been rewritten without using ES6 generators in order
to avoid V8's TurboFan/Crankshift optimization bailout.
This commit is contained in:
Zaid Abdulla committed 2017-02-15 02:19:02 -08:00
1 parent a48984b909
commit 3223e9733a
5 files changed
+115 -138

No files matched your search

+5 -5
View File
@@ -96,7 +96,7 @@ function getAliasDeclarations(path, timestamp) {
function unpack(deviceData, path, revision) {
let allMatches = [];
if (!path.alias) {
for (let p of deviceData.paths.subset(path, 0))
for (let p of deviceData.paths.find(path, false, true))
if (deviceData.attributes.has(p, revision))
allMatches.push(p);
}
@@ -109,7 +109,7 @@ function unpack(deviceData, path, revision) {
wildcardPath.wildcard |= 1 << i;
}
for (let p of deviceData.paths.subset(wildcardPath, 0))
for (let p of deviceData.paths.find(wildcardPath, false, true))
if (deviceData.attributes.has(p, revision))
allMatches.push(p);
@@ -169,7 +169,7 @@ function unpack(deviceData, path, revision) {
function clear(deviceData, path, timestamp, attributes) {
for (let p of deviceData.paths.all(path, timestamp ? 99 : 0)) {
for (let p of deviceData.paths.find(path, true, true, timestamp ? 99 : path.length)) {
for (let k in deviceData.trackers.get(p))
deviceData.changes.add(k);
@@ -279,7 +279,7 @@ function set(deviceData, path, timestamp, attributes, toClear) {
}
if (changeFlags)
for (let sup of deviceData.paths.superset(path)) {
for (let sup of deviceData.paths.find(path, true, false)) {
let c = deviceData.trackers.get(sup);
for (let k in c)
if (c[k] & changeFlags) {
@@ -309,7 +309,7 @@ function set(deviceData, path, timestamp, attributes, toClear) {
}
if (path.wildcard)
for (let sub of deviceData.paths.subset(path))
for (let sub of deviceData.paths.find(path, false, true))
if (timestamp > deviceData.timestamps.get(sub)) {
deviceData.timestamps.delete(sub);
if (deviceData.attributes.delete(sub)) {