diff options
author | Sean Allred <code@seanallred.com> | 2014-11-02 08:55:53 -0500 |
---|---|---|
committer | Sean Allred <code@seanallred.com> | 2014-11-02 09:03:13 -0500 |
commit | 39ec0ba8a34b3764fcf46f0e5deb1133b0e70e2c (patch) | |
tree | 4377a39ec2cd28162cbd3db9ce6cd5bb515783b7 /stack-core.el | |
parent | 6d6fe8e7b7f0bb99b2895fe53c811857ce65e275 (diff) |
Use a simpler construct to test filter inclusion
Also removed tests for `stack-core-filter-data--item-in-tree' since it
no longer exists.
Diffstat (limited to 'stack-core.el')
-rw-r--r-- | stack-core.el | 23 |
1 files changed, 7 insertions, 16 deletions
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 |