diff options
author | Eduardo Julian | 2016-10-13 02:40:41 -0400 |
---|---|---|
committer | Eduardo Julian | 2016-10-13 02:40:41 -0400 |
commit | 030c21a6b4881181ccdb89862201405ca1aa81c4 (patch) | |
tree | 40bd3e3c894326e559ca6c9b1c4b797071956204 | |
parent | 90bd4d494778725f45ad39bf1449ca456b3ea57a (diff) |
- Now simplifying the PM paths to get rid of some of the pointless testing that results from ignoring some local bindings.
-rw-r--r-- | src/lux/optimizer.clj | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/lux/optimizer.clj b/src/lux/optimizer.clj index 23b595886..f97f7810f 100644 --- a/src/lux/optimizer.clj +++ b/src/lux/optimizer.clj @@ -522,14 +522,33 @@ body ))) +(defn ^:private simplify-pattern [pattern] + (|case pattern + ($SeqPM ($TuplePM _idx) ($SeqPM ($PopPM) pattern*)) + (simplify-pattern pattern*) + + ($SeqPM ($TuplePM _idx) _right) + (|case (simplify-pattern _right) + ($SeqPM ($PopPM) pattern*) + pattern* + + _right* + ($SeqPM ($TuplePM _idx) _right*)) + + ($SeqPM _left _right) + ($SeqPM _left (simplify-pattern _right)) + + _ + pattern)) + (defn ^:private optimize-register-use [pattern body] (|let [p-vars (pattern-vars pattern) p-vars* (find-unused-vars p-vars body) adjusted-vars (adjust-register-indexes p-vars*) clean-pattern (clean-unused-pattern-registers adjusted-vars pattern) + simple-pattern (simplify-pattern clean-pattern) clean-body (clean-unused-body-registers adjusted-vars body)] - (&/T [clean-pattern - clean-body]))) + (&/T [simple-pattern clean-body]))) ;; This is the top-level function for optimizing PM, which transforms ;; each branch and then fuses them together. |