eyeprolog 1.6.24 → 1.6.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/solver.js +10 -1
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.6.24",
6
+ "version": "1.6.26",
7
7
  "description": "EyeProlog turns facts and rules into answers and proofs.",
8
8
  "type": "module",
9
9
  "main": "./index.js",
package/src/solver.js CHANGED
@@ -3291,7 +3291,16 @@ function headCannotMatch(goal, head, env) {
3291
3291
  }
3292
3292
 
3293
3293
  function goalHeadTermsCannotMatch(goalTerm, headTerm, env) {
3294
- const pending = [[goalTerm, headTerm]];
3294
+ // Scalar comparisons dominate indexed clause checks. Avoid allocating a
3295
+ // traversal stack until a compound argument needs its children checked.
3296
+ const first = derefForLocal(goalTerm, env);
3297
+ if (first.type === VAR || headTerm.type === VAR) return false;
3298
+ if (first.type !== headTerm.type || first.name !== headTerm.name || first.arity !== headTerm.arity) return true;
3299
+ if (first.type !== COMPOUND) return false;
3300
+ const pending = [];
3301
+ for (let index = 0; index < first.arity; index++) {
3302
+ pending.push([first.args[index], headTerm.args[index]]);
3303
+ }
3295
3304
  while (pending.length > 0) {
3296
3305
  const [goalItem, headItem] = pending.pop();
3297
3306
  const actual = derefForLocal(goalItem, env);