[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash 9065e1b 344/439: [-let] Final cdr shift optimizati
From: |
Phillip Lord |
Subject: |
[elpa] externals/dash 9065e1b 344/439: [-let] Final cdr shift optimization |
Date: |
Tue, 04 Aug 2015 20:30:01 +0000 |
branch: externals/dash
commit 9065e1bdaa990b38ab22cb32b9b8132e58c71612
Author: Matus Goljer <address@hidden>
Commit: Matus Goljer <address@hidden>
[-let] Final cdr shift optimization
---
dash.el | 16 ++++++++++++----
dev/examples.el | 8 +++++++-
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/dash.el b/dash.el
index 7e7db7e..a66d3cb 100644
--- a/dash.el
+++ b/dash.el
@@ -1198,11 +1198,19 @@ SOURCE is a proper or improper list."
;; because each bind-body has a side-effect of chopping the head
;; of the list, we must create a binding even for _ places
((symbolp (car match-form))
- (cons (list (car match-form) `(prog1 (car ,s) (!cdr ,s)))
- (dash--match-cons-1 (cdr match-form) s)))
+ (cond
+ ((cdr match-form)
+ (cons (list (car match-form) `(prog1 (car ,s) (!cdr ,s)))
+ (dash--match-cons-1 (cdr match-form) s)))
+ (t
+ (list (list (car match-form) `(car ,s))))))
(t
- (-concat (dash--match (car match-form) `(prog1 (car ,s) (!cdr ,s)))
- (dash--match-cons-1 (cdr match-form) s)))))
+ (cond
+ ((cdr match-form)
+ (-concat (dash--match (car match-form) `(prog1 (car ,s) (!cdr ,s)))
+ (dash--match-cons-1 (cdr match-form) s)))
+ (t
+ (dash--match (car match-form) `(car ,s)))))))
((eq match-form nil)
nil)
(t
diff --git a/dev/examples.el b/dev/examples.el
index aa171f4..ae4c643 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -740,7 +740,13 @@ new list."
(list a b c d)
(error "previous call should fail.")))
(error t)) => t
- (-let [(a . (b . c)) (cons 1 (cons 2 3))] (list a b c)) => '(1 2 3))
+ (-let [(a . (b . c)) (cons 1 (cons 2 3))] (list a b c)) => '(1 2 3)
+ ;; final cdr optimization
+ (-let [(((a))) (list (list (list 1 2) 3) 4)] a) => 1
+ (-let [(((a b) c) d) (list (list (list 1 2) 3) 4)] (list a b c d)) => '(1
2 3 4)
+ (-let [(((a b) . c) . d) (list (list (list 1 2) 3) 4)] (list a b c d)) =>
'(1 2 (3) (4))
+ (-let [(((a b) c)) (list (list (list 1 2) 3) 4)] (list a b c)) => '(1 2 3)
+ (-let [(((a b) . c)) (list (list (list 1 2) 3) 4)] (list a b c)) => '(1 2
(3)))
(defexamples -let*
(-let* (((a . b) (cons 1 2))
- [elpa] externals/dash ab99be6 335/439: Add -fix, (continued)
- [elpa] externals/dash ab99be6 335/439: Add -fix, Phillip Lord, 2015/08/04
- [elpa] externals/dash 2626840 336/439: Add -fixfn, Phillip Lord, 2015/08/04
- [elpa] externals/dash c6b92ae 324/439: Reorder the examples into more meaningful blocks, Phillip Lord, 2015/08/04
- [elpa] externals/dash b1e585d 337/439: Update copyright notice, Phillip Lord, 2015/08/04
- [elpa] externals/dash f0831d3 339/439: Add -lambda, Phillip Lord, 2015/08/04
- [elpa] externals/dash 8f9fc41 340/439: Add support for multiple input arguments to -lambda, Phillip Lord, 2015/08/04
- [elpa] externals/dash 05fa92f 342/439: [-let] Transpose nreverse/flatten, Phillip Lord, 2015/08/04
- [elpa] externals/dash 7f2b3c7 343/439: [-lambda] test all match-forms before converting to regular lambda, Phillip Lord, 2015/08/04
- [elpa] externals/dash 947ffda 341/439: Add support for &rest match for non-list sequences (like . for improper lists), Phillip Lord, 2015/08/04
- [elpa] externals/dash a4be872 338/439: Add `-let` and `-let*`, Phillip Lord, 2015/08/04
- [elpa] externals/dash 9065e1b 344/439: [-let] Final cdr shift optimization,
Phillip Lord <=
- [elpa] externals/dash 6f81492 346/439: [-lambda] Better error-handling, Phillip Lord, 2015/08/04
- [elpa] externals/dash 65a3736 349/439: [-let] Fix improper list non-symbol last argument handler, Phillip Lord, 2015/08/04
- [elpa] externals/dash 4d67b25 345/439: [-let] Do not reinvent `pop', Phillip Lord, 2015/08/04
- [elpa] externals/dash f939201 347/439: [-let] Optimize shifting/binding of unused _ places, Phillip Lord, 2015/08/04
- [elpa] externals/dash 51a0c9f 350/439: [-let] Fix expansion of _ symbols in vector matcher, Phillip Lord, 2015/08/04
- [elpa] externals/dash 0fc5d73 351/439: [-let] Make the cons matcher temp-bind as late as possible, Phillip Lord, 2015/08/04
- [elpa] externals/dash f7664c6 352/439: [-let] Add &keys support for cons matcher, Phillip Lord, 2015/08/04
- [elpa] externals/dash 6f0bb7d 348/439: [-let] Fix dynamic scoping issue, Phillip Lord, 2015/08/04
- [elpa] externals/dash db7f651 353/439: [-let] Simplify the conditions in dash--match-cons-1, Phillip Lord, 2015/08/04
- [elpa] externals/dash 9ec1a02 354/439: [-let] Abstract the _ test into a function, Phillip Lord, 2015/08/04