Browse Source

Optimize recursive constant dependency

master
Jordi Baylina 4 years ago
parent
commit
5dc54bb7d2
No known key found for this signature in database GPG Key ID: 7480C80C1BE43112
1 changed files with 10 additions and 3 deletions
  1. +10
    -3
      src/compiler.js

+ 10
- 3
src/compiler.js

@ -346,17 +346,24 @@ async function reduceConstrains(ctx) {
} else { } else {
nextPossibleConstraints = {}; nextPossibleConstraints = {};
} }
removedSignals = new BigArray();
removedSignals = {};
nRemoved = 0; nRemoved = 0;
lIdx = new BigArray();
lIdx = {};
for (let i=0;i<possibleConstraints.length;i++) { for (let i=0;i<possibleConstraints.length;i++) {
if ((ctx.verbose)&&(i%10000 == 0)) { if ((ctx.verbose)&&(i%10000 == 0)) {
await Promise.resolve(); await Promise.resolve();
console.log(`reducing constraints: ${i}/${possibleConstraints.length} reduced: ${nRemoved}`); console.log(`reducing constraints: ${i}/${possibleConstraints.length} reduced: ${nRemoved}`);
} }
const c = ctx.constraints[possibleConstraints[i]]; const c = ctx.constraints[possibleConstraints[i]];
if (!c) continue; if (!c) continue;
// Limit of number of lelements removed per step
if (nRemoved>100000) {
nextPossibleConstraints[possibleConstraints[i]] = true;
continue;
}
// Swap a and b if b has more variables. // Swap a and b if b has more variables.
if (Object.keys(c.b).length > Object.keys(c.a).length) { if (Object.keys(c.b).length > Object.keys(c.a).length) {
const aux = c.a; const aux = c.a;
@ -434,7 +441,7 @@ async function reduceConstrains(ctx) {
} }
} }
const removedSignalsList = removedSignals.getKeys();
const removedSignalsList = Object.keys(removedSignals);
for (let i=0; i<removedSignalsList.length; i++) { for (let i=0; i<removedSignalsList.length; i++) {
if ((ctx.verbose )&&(i%100000 == 0)) console.log(`removing signals: ${i}/${removedSignalsList.length}`); if ((ctx.verbose )&&(i%100000 == 0)) console.log(`removing signals: ${i}/${removedSignalsList.length}`);

Loading…
Cancel
Save