From: Artur Malabarba Date: Sun, 26 Apr 2015 18:01:55 +0000 (+0100) Subject: * bug-hunter.el: Reduce number of steps X-Git-Url: https://code.delx.au/gnu-emacs-elpa/commitdiff_plain/d1465c90dc30f878537ec95b7548aa45e8269b7b * bug-hunter.el: Reduce number of steps --- diff --git a/packages/bug-hunter/bug-hunter.el b/packages/bug-hunter/bug-hunter.el index 70bae255d..8dcd7a632 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.