From 39ec0ba8a34b3764fcf46f0e5deb1133b0e70e2c Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Sun, 2 Nov 2014 08:55:53 -0500 Subject: Use a simpler construct to test filter inclusion Also removed tests for `stack-core-filter-data--item-in-tree' since it no longer exists. --- stack-core.el | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'stack-core.el') diff --git a/stack-core.el b/stack-core.el index 45d7cb3..9a535cd 100644 --- a/stack-core.el +++ b/stack-core.el @@ -225,8 +225,13 @@ entire response as a complex alist." (delq nil (mapcar (lambda (cons-cell) - (let ((f (stack-core-filter-data--item-in-tree - (car cons-cell) desired-tree))) + ;; TODO the resolution of `f' is O(2n) in the worst + ;; case. It may be faster to implement the same + ;; functionality as a `while' loop to stop looking the + ;; list once it has found a match. Do speed tests. + ;; See edfab4443ec3d376c31a38bef12d305838d3fa2e. + (let ((f (or (memq (car cons-cell) desired-tree) + (assoc (car cons-cell) desired-tree)))) (when f (if (and (sequencep (cdr cons-cell)) (sequencep (elt (cdr cons-cell) 0))) @@ -236,19 +241,5 @@ entire response as a complex alist." cons-cell)))) data)))) -(defun stack-core-filter-data--item-in-tree (item tree) - "Check if ITEM is in the direct leaves of TREE - -For example, when called with (f 'item '(some item here)), the -return would be `t'. When called as (f 'item '(some (item here) -in a (deep structure))), `(item here)' would be returned. -" - (when tree - (if (equal item (car tree)) tree - (if (and (listp (car tree)) - (equal item (caar tree))) - (car tree) - (stack-core-filter-data--item-in-tree item (cdr tree)))))) - (provide 'stack-core) ;;; stack-core.el ends here -- cgit v1.2.3