summaryrefslogtreecommitdiff
path: root/lisp/subr.el
diff options
context:
space:
mode:
authorMattias EngdegÄrd <mattiase@acm.org>2022-09-16 15:29:03 +0200
committerMattias EngdegÄrd <mattiase@acm.org>2022-09-16 15:33:12 +0200
commit4da0fbdc82577da0583c8858a52f456beb23fd0e (patch)
tree42933fcb0f05db0327d6b8f546f21f07a2aaf6ec /lisp/subr.el
parent838e6cae81392139377dd8b78b52ff3aaeba2fc1 (diff)
downloademacs-4da0fbdc82577da0583c8858a52f456beb23fd0e.tar.gz
emacs-4da0fbdc82577da0583c8858a52f456beb23fd0e.tar.bz2
emacs-4da0fbdc82577da0583c8858a52f456beb23fd0e.zip
Faster and more robust list-of-strings-p
* lisp/subr.el (list-of-strings-p): Speed up by a factor 4 (approx.) and don't crash on dotted lists. * test/lisp/subr-tests.el (test-list-of-strings-p): Extend test.
Diffstat (limited to 'lisp/subr.el')
-rw-r--r--lisp/subr.el5
1 files changed, 3 insertions, 2 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index e8e8f1584b4..caea2b9f933 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -4028,8 +4028,9 @@ Otherwise, return nil."
(defun list-of-strings-p (object)
"Return t if OBJECT is nil or a list of strings."
- (and (listp object)
- (seq-every-p #'stringp object)))
+ (while (and (consp object) (stringp (car object)))
+ (setq object (cdr object)))
+ (null object))
(defun booleanp (object)
"Return t if OBJECT is one of the two canonical boolean values: t or nil.