From: Glenn Morris Date: Wed, 14 May 2014 06:35:36 +0000 (-0700) Subject: Optimize away some compat-cruft in printing.el X-Git-Url: https://git.hcoop.net/bpt/emacs.git/commitdiff_plain/f0036ec2d210796144fb41381a0841130734e13a Optimize away some compat-cruft in printing.el * lisp/printing.el (subst-char-in-string, make-temp-file, pr-get-symbol): Optimize on Emacs, which has the relevant functions for ages. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index cd2ce4e874..0b25744466 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2014-05-14 Glenn Morris + + * printing.el (subst-char-in-string, make-temp-file, pr-get-symbol): + Optimize on Emacs, which has the relevant functions for ages. + 2014-05-13 Stefan Monnier * simple.el (undo-make-selective-list): Obey undo-no-redo. diff --git a/lisp/printing.el b/lisp/printing.el index 0393746f8a..de7958ea0e 100644 --- a/lisp/printing.el +++ b/lisp/printing.el @@ -1038,20 +1038,27 @@ Please send all bug fixes and enhancements to ;; To avoid compilation gripes -(or (fboundp 'subst-char-in-string) ; hacked from subr.el - (defun subst-char-in-string (fromchar tochar string &optional inplace) - "Replace FROMCHAR with TOCHAR in STRING each time it occurs. +;; Emacs has this since at least 21.1. +(when (featurep 'xemacs) + (or (fboundp 'subst-char-in-string) ; hacked from subr.el + (defun subst-char-in-string (fromchar tochar string &optional inplace) + "Replace FROMCHAR with TOCHAR in STRING each time it occurs. Unless optional argument INPLACE is non-nil, return a new string." - (let ((i (length string)) - (newstr (if inplace string (copy-sequence string)))) - (while (> (setq i (1- i)) 0) - (if (eq (aref newstr i) fromchar) - (aset newstr i tochar))) - newstr))) - - -(or (fboundp 'make-temp-file) ; hacked from subr.el - (defun make-temp-file (prefix &optional dir-flag suffix) + (let ((i (length string)) + (newstr (if inplace string (copy-sequence string)))) + (while (> (setq i (1- i)) 0) + (if (eq (aref newstr i) fromchar) + (aset newstr i tochar))) + newstr)))) + + +;; Emacs has this since at least 21.1, but the SUFFIX argument +;; (which this file uses) only since 22.1. So the fboundp test +;; wasn't even correct/adequate. Whatever, no-one is using +;; this file on older Emacs version, so it's irrelevant. +(when (featurep 'xemacs) + (or (fboundp 'make-temp-file) ; hacked from subr.el + (defun make-temp-file (prefix &optional dir-flag suffix) "Create a temporary file. The returned file name (created by appending some random characters at the end of PREFIX, and expanding against `temporary-file-directory' if necessary), @@ -1086,7 +1093,7 @@ If SUFFIX is non-nil, add that at the end of the file name." nil) file) ;; Reset the umask. - (set-default-file-modes umask))))) + (set-default-file-modes umask)))))) (eval-when-compile @@ -3192,9 +3199,10 @@ See `pr-ps-printer-alist'.") (defalias 'pr-get-symbol - (if (fboundp 'easy-menu-intern) ; hacked from easymenu.el - 'easy-menu-intern - (lambda (s) (if (stringp s) (intern s) s)))) + (if (featurep 'emacs) 'easy-menu-intern ; since 22.1 + (if (fboundp 'easy-menu-intern) ; hacked from easymenu.el + 'easy-menu-intern + (lambda (s) (if (stringp s) (intern s) s))))) (defconst pr-menu-spec