diff options
author | Eduardo Julian | 2016-06-13 00:40:37 -0400 |
---|---|---|
committer | Eduardo Julian | 2016-06-13 00:40:37 -0400 |
commit | ade08bbd52acaf3bb51e1a3a1c1cd73bb1ba9948 (patch) | |
tree | 975a72cfc17fded0cc1817c0f49ff5246f93f487 | |
parent | 1c2652155c0483cf3f8e7400c9ca48eefe0c34cc (diff) |
- Now avoiding unnecessary pops of the pattern-matching stack/cursor.
Diffstat (limited to '')
-rw-r--r-- | src/lux/optimizer.clj | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/lux/optimizer.clj b/src/lux/optimizer.clj index 8c3380b0a..24636bf16 100644 --- a/src/lux/optimizer.clj +++ b/src/lux/optimizer.clj @@ -100,10 +100,18 @@ _sub-tests)) (&/|list $PopPM)))))) +(defn ^:private clean-unnecessary-pops [steps] + (|case steps + (&/$Cons ($PopPM) _steps) + (clean-unnecessary-pops _steps) + + _ + steps)) + (defn ^:private transform-pm [test body-id] - (|case (&/|reverse (&/|++ (transform-pm* test) (&/|list ($ExecPM body-id)))) - (&/$Cons _last _prevs) - (&/fold (fn [right left] ($SeqPM left right)) _last _prevs))) + (&/fold (fn [right left] ($SeqPM left right)) + ($ExecPM body-id) + (clean-unnecessary-pops (&/|reverse (transform-pm* test))))) (defn ^:private fuse-pms [pre post] (|case (&/T [pre post]) |