From b8b1d8dee7e30415b057b7a45f288fda3601274f Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Sun, 26 Sep 2021 15:29:20 +0200 Subject: [PATCH] Add fast-path to ert--explain-string-equal MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * lisp/emacs-lisp/ert.el (ert--explain-string-equal): Add fast-path to avoid doing extra work. Problem reported by Mattias Engdegård . --- lisp/emacs-lisp/ert.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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) -- 2.39.2