* Prevent repeated wrapping of closed terms

(closed(closed(closed(...)))) since this reduces performance by
  producing bigger terms and killing caching (which incidentally also
  prevents useful infinite recursion detection).
This commit is contained in:
Eelco Dolstra 2005-07-19 11:48:05 +00:00
parent 2135e7c041
commit 0f827cc607

View file

@ -233,7 +233,12 @@ Expr substitute(const ATermMap & subs, Expr e)
if (matchVar(e, name)) {
Expr sub = subs.get(name);
return sub ? makeClosed(sub) : e;
Expr wrapped;
/* Add a "closed" wrapper around terms that aren't already
closed. The check is necessary to prevent repeated
wrapping, e.g., closed(closed(closed(...))), which kills
caching. */
return sub ? (matchClosed(sub, wrapped) ? sub : makeClosed(sub)) : e;
}
/* In case of a function, filter out all variables bound by this