diff lisp/cl-macs.el @ 4723:ebca981a0012

If STRING is constant, call regexp-quote at compile time. 2009-10-30 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (regexp-quote): If STRING is constant, call regexp-quote at compile time.
author Aidan Kehoe <kehoea@parhasard.net>
date Fri, 30 Oct 2009 15:10:16 +0000
parents bd51ab22afa8
children 4cf435fcebbc
line wrap: on
line diff
--- a/lisp/cl-macs.el	Mon Oct 26 15:41:26 2009 -0600
+++ b/lisp/cl-macs.el	Fri Oct 30 15:10:16 2009 +0000
@@ -3271,6 +3271,14 @@
       form
     (cons 'mapcar (cdr form))))
 
+;; XEmacs; it's perfectly reasonable, and often much clearer to those
+;; reading the code, to call regexp-quote on a constant string, which is
+;; something we can optimise here easily.
+(define-compiler-macro regexp-quote (&whole form string)
+  (if (stringp string)
+      (regexp-quote string)
+    form))
+
 (mapc
  #'(lambda (y)
      (put (car y) 'side-effect-free t)