[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master d1465c9 2/3: * bug-hunter.el: Reduce number of steps
From: |
Artur Malabarba |
Subject: |
[elpa] master d1465c9 2/3: * bug-hunter.el: Reduce number of steps |
Date: |
Sun, 26 Apr 2015 18:04:18 +0000 |
branch: master
commit d1465c90dc30f878537ec95b7548aa45e8269b7b
Author: Artur Malabarba <address@hidden>
Commit: Artur Malabarba <address@hidden>
* bug-hunter.el: Reduce number of steps
---
packages/bug-hunter/bug-hunter.el | 40 ++++++++++++++++++++----------------
1 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/packages/bug-hunter/bug-hunter.el
b/packages/bug-hunter/bug-hunter.el
index 70bae25..8dcd7a6 100644
--- a/packages/bug-hunter/bug-hunter.el
+++ b/packages/bug-hunter/bug-hunter.el
@@ -262,25 +262,29 @@ ASSERTION is received by `bug-hunter--bisect-start'.
SAFE is a list of forms confirmed to not match the ASSERTION,
HEAD is a list of forms to be tested now, and TAIL is a list
which will be inspected if HEAD doesn't match ASSERTION."
- (cond
- ((not tail)
- (vector (length safe)
- ;; Sometimes we already ran this, sometimes not. So it's
- ;; easier to just run it anyway to get the return value.
- (bug-hunter--run-and-test (append safe head) assertion)))
- ((and (message "Testing: %s/%s"
- (cl-incf bug-hunter--i)
- bug-hunter--estimate)
- (setq bug-hunter--current-head head)
- (bug-hunter--run-and-test (append safe head) assertion))
- (apply #'bug-hunter--bisect
- assertion
- safe
- (bug-hunter--split head)))
- (t (apply #'bug-hunter--bisect
+ (message "Testing: %s/%s" (cl-incf bug-hunter--i) bug-hunter--estimate)
+ ;; Used if the user quits.
+ (setq bug-hunter--current-head head)
+ (let ((ret-val (bug-hunter--run-and-test (append safe head) assertion)))
+ (cond
+ ((not tail)
+ (cl-assert ret-val nil)
+ (vector (length safe) ret-val))
+ ;; Issue in the head.
+ ((and ret-val (< (length head) 2))
+ (vector (length safe) ret-val))
+ (ret-val
+ (apply #'bug-hunter--bisect
assertion
- (append safe head)
- (bug-hunter--split tail)))))
+ safe
+ (bug-hunter--split head)))
+ ;; Issue in the tail.
+ (t (apply #'bug-hunter--bisect
+ assertion
+ (append safe head)
+ ;; If tail has length 1, we already know where the issue is,
+ ;; but we still do this to get the return value.
+ (bug-hunter--split tail))))))
(defun bug-hunter--bisect-start (forms assertion)
"Run a bisection search on list of FORMS using ASSERTION.