[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash c1d555b 355/439: [-let] Optimize single-binding of
From: |
Phillip Lord |
Subject: |
[elpa] externals/dash c1d555b 355/439: [-let] Optimize single-binding of vectors and kv |
Date: |
Tue, 04 Aug 2015 20:30:21 +0000 |
branch: externals/dash
commit c1d555bd46f78e0eb0511657d438e1ee87b4dbd8
Author: Matus Goljer <address@hidden>
Commit: Matus Goljer <address@hidden>
[-let] Optimize single-binding of vectors and kv
---
dash.el | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/dash.el b/dash.el
index a6d1a3b..cb84710 100644
--- a/dash.el
+++ b/dash.el
@@ -1280,7 +1280,18 @@ SOURCE is a proper or improper list."
(defun dash--match-vector (match-form source)
"Setup a vector matching environment and call the real matcher."
(let ((s (make-symbol "--dash-source--")))
- (cons (list s source) (dash--match-vector-1 match-form s))))
+ (cond
+ ;; don't bind `s' if we only have one sub-pattern
+ ((= (length match-form) 1)
+ (dash--match (aref match-form 0) `(aref ,source 0)))
+ ;; don't bind `s' if we only have one sub-pattern which is not ignored
+ ((let* ((ignored-places (mapcar 'dash--match-ignore-place-p match-form))
+ (ignored-places-n (length (-remove 'null ignored-places))))
+ (when (= ignored-places-n (1- (length match-form)))
+ (let ((n (-find-index 'null ignored-places)))
+ (dash--match (aref match-form n) `(aref ,source ,n))))))
+ (t
+ (cons (list s source) (dash--match-vector-1 match-form s))))))
(defun dash--match-vector-1 (match-form source)
"Match MATCH-FORM against SOURCE.
@@ -1330,7 +1341,12 @@ is discarded."
kv can be any key-value store, such as plist, alist or hash-table."
(let ((s (make-symbol "--dash-source--")))
- (cons (list s source) (dash--match-kv-1 (cdr match-form) s (car
match-form)))))
+ (cond
+ ;; don't bind `s' if we only have one sub-pattern (&type key val)
+ ((= (length match-form) 3)
+ (dash--match-kv-1 (cdr match-form) source (car match-form)))
+ (t
+ (cons (list s source) (dash--match-kv-1 (cdr match-form) s (car
match-form)))))))
(defun dash--match-kv-1 (match-form source type)
"Match MATCH-FORM against SOURCE of type TYPE.
- [elpa] externals/dash 6f81492 346/439: [-lambda] Better error-handling, (continued)
- [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
- [elpa] externals/dash c1d555b 355/439: [-let] Optimize single-binding of vectors and kv,
Phillip Lord <=
- [elpa] externals/dash 0310e0e 359/439: Update docs, Phillip Lord, 2015/08/04
- [elpa] externals/dash 40849a7 357/439: [-let] Remove stale comment, Phillip Lord, 2015/08/04
- [elpa] externals/dash edb1e31 356/439: [-let] Add more tests, Phillip Lord, 2015/08/04
- [elpa] externals/dash 4b63be1 362/439: Declare --mapcat macro before using it. #102, Phillip Lord, 2015/08/04
- [elpa] externals/dash 31f321a 358/439: Release 2.9.0, Phillip Lord, 2015/08/04
- [elpa] externals/dash 2436bf8 361/439: Add debug declaration on -lambda, Phillip Lord, 2015/08/04
- [elpa] externals/dash 9e1a667 360/439: Do not map nodes on conses (be consistent with tree map), Phillip Lord, 2015/08/04
- [elpa] externals/dash 75d29a2 363/439: Declare --iterate macro before using it. #102, Phillip Lord, 2015/08/04
- [elpa] externals/dash 3bdf60b 365/439: Add some examples, Phillip Lord, 2015/08/04
- [elpa] externals/dash 03b98ca 364/439: Make -if-let and -when-let families destructure their arguments, Phillip Lord, 2015/08/04