Optimize PathSet

Performance has not been tested but generally avoiding sparse arrays
should result in better performance.
This commit is contained in:
Zaid Abdulla committed 2018-09-08 23:49:14 -07:00
1 parent c2d55f08d4
commit 037aa9786d
2 files changed
+41 -41

No files matched your search

+7 -7
View File
@@ -1808,12 +1808,11 @@ function processDeclarations(
const syncState = sessionContext.syncState;
const root = sessionContext.deviceData.paths.add([]);
const paths = sessionContext.deviceData.paths.find([], false, true, 99);
paths.sort((a, b) => {
if (a.wildcard === b.wildcard) return a.length - b.length;
return a.wildcard - b.wildcard;
});
const paths = deviceData.paths.find([], false, true, 99);
paths.sort(
(a, b) =>
a.wildcard === b.wildcard ? a.length - b.length : a.wildcard - b.wildcard
);
const virtualParameterDeclarations = [];
@@ -1885,7 +1884,8 @@ function processDeclarations(
leafIsObject = currentAttributes.object
? currentAttributes.object[1]
: null;
if (leafIsObject === 0)
// Possible V8 bug causes null === 0
if (leafIsObject != null && leafIsObject === 0)
leafTimestamp = Math.max(leafTimestamp, currentAttributes.object[0]);
} else {
leafTimestamp = Math.max(leafTimestamp, currentTimestamp);