changeset 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 dfc9fe46c294
children 5690bb2e7a44
files lisp/ChangeLog lisp/cl-macs.el
diffstat 2 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Mon Oct 26 15:41:26 2009 -0600
+++ b/lisp/ChangeLog	Fri Oct 30 15:10:16 2009 +0000
@@ -1,3 +1,8 @@
+2009-10-30  Aidan Kehoe  <kehoea@parhasard.net>
+
+	* cl-macs.el (regexp-quote): 
+	If STRING is constant, call regexp-quote at compile time.
+
 2009-10-24  Aidan Kehoe  <kehoea@parhasard.net>
 
 	* files.el (default-file-system-ignore-case): New variable.
--- 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)