From: Stefan Kangas Date: Sun, 26 Sep 2021 13:29:20 +0000 (+0200) Subject: Add fast-path to ert--explain-string-equal X-Git-Tag: emacs-28.0.90~598 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b8b1d8dee7e30415b057b7a45f288fda3601274f;p=emacs.git Add fast-path to ert--explain-string-equal * lisp/emacs-lisp/ert.el (ert--explain-string-equal): Add fast-path to avoid doing extra work. Problem reported by Mattias EngdegÄrd . --- diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el index e72321f90ff..72fe19461f7 100644 --- a/lisp/emacs-lisp/ert.el +++ b/lisp/emacs-lisp/ert.el @@ -543,9 +543,11 @@ Returns nil if they are." (defun ert--explain-string-equal (a b) "Explainer function for `string-equal'." ;; Convert if they are symbols. - (let ((as (if (symbolp a) (symbol-name a) a)) - (bs (if (symbolp b) (symbol-name b) b))) - (ert--explain-equal-rec as bs))) + (if (string-equal a b) + nil + (let ((as (if (symbolp a) (symbol-name a) a)) + (bs (if (symbolp b) (symbol-name b) b))) + (ert--explain-equal-rec as bs)))) (put 'string-equal 'ert-explainer 'ert--explain-string-equal) (defun ert--significant-plist-keys (plist)