From: keiichi Date: Fri, 28 May 1999 06:04:13 +0000 (+0000) Subject: Add `byte-optimizer' to `buffer-string', `backward-char' and `char-before'. X-Git-Tag: nana-gnus-6_12_17~4 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=8c8bff46a07cdb5457ae573556f685983eb5c5c3;p=elisp%2Fgnus.git- Add `byte-optimizer' to `buffer-string', `backward-char' and `char-before'. ;; Thanks for Shuhei KOBAYASHI's suggestion. --- diff --git a/lisp/dgnushack.el b/lisp/dgnushack.el index 051c2f5..1715518 100644 --- a/lisp/dgnushack.el +++ b/lisp/dgnushack.el @@ -49,6 +49,29 @@ (fset 'x-defined-colors 'ignore) (fset 'read-color 'ignore))) +(eval-and-compile + (put 'buffer-string 'byte-optimizer 'byte-optimize-buffer-string) + (defun byte-optimize-buffer-string (form) + (if (null (cdr form)) + (list 'buffer-substring (list 'point-min)(list 'point-max)) + form)) + + (put 'backward-char 'byte-optimizer 'byte-optimize-backward-char) + (defun byte-optimize-backward-char (form) + (if (null (cdr form)) + (list 'forward-char -1) + (list 'forward-char (list '- (nth 1 form))))) + + (when (or (featurep 'xemacs) + (and (= emacs-major-version 20) + (> emacs-minor-version 2))) + ;; this optimization is not safe under Emacs 20.2 and before. + (put 'char-before 'byte-optimizer 'byte-optimize-char-before) + (defun byte-optimize-char-before (form) + (if (null (cdr form)) + (list 'char-after (list '1- (list 'point))) + (list 'char-after (list '1- (nth 1 form))))))) + (defun dgnushack-compile (&optional warn) ;;(setq byte-compile-dynamic t) (unless warn