emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master be30748: * lisp: Prefer inlinable functions to macr


From: Stefan Monnier
Subject: [Emacs-diffs] master be30748: * lisp: Prefer inlinable functions to macros.
Date: Fri, 05 Dec 2014 17:49:59 +0000

branch: master
commit be307485f722be57985da979296fa37569c2a5a9
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    * lisp: Prefer inlinable functions to macros.
    
    * lisp/fringe.el (fringe-bitmap-p): Make it a plain function.
    
    * lisp/tooltip.el (tooltip-region-active-p): Remove.
    
    * lisp/net/shr.el (shr-char-breakable-p, shr-char-kinsoku-bol-p)
    (shr-char-kinsoku-eol-p, shr-char-nospace-p): Use define-inline.
    
    * lisp/url/url-future.el (url-future-done-p, url-future-completed-p)
    (url-future-errored-p, url-future-cancelled-p):
    * lisp/url/url-dav.el (url-dav-http-success-p): Use define-inline.
    
    * lisp/vc/ediff-init.el (ediff-odd-p): Remove.
    (ediff-background-face): Use cl-oddp instead.
    (ediff-buffer-live-p): Make it a defsubst.
---
 lisp/ChangeLog              |   11 +++++++++++
 lisp/emacs-lisp/bytecomp.el |    4 ++++
 lisp/fringe.el              |    2 +-
 lisp/net/shr.el             |   20 ++++++++++----------
 lisp/tooltip.el             |    6 +-----
 lisp/url/ChangeLog          |    6 ++++++
 lisp/url/url-dav.el         |    4 ++--
 lisp/url/url-future.el      |   16 ++++++++--------
 lisp/vc/ediff-init.el       |   11 +++++------
 9 files changed, 48 insertions(+), 32 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 54e0804..2c6c377 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,16 @@
 2014-12-05  Stefan Monnier  <address@hidden>
 
+       * vc/ediff-init.el (ediff-odd-p): Remove.
+       (ediff-background-face): Use cl-oddp instead.
+       (ediff-buffer-live-p): Make it a defsubst.
+
+       * tooltip.el (tooltip-region-active-p): Remove.
+
+       * net/shr.el (shr-char-breakable-p, shr-char-kinsoku-bol-p)
+       (shr-char-kinsoku-eol-p, shr-char-nospace-p): Use define-inline.
+
+       * fringe.el (fringe-bitmap-p): Make it a plain function.
+
        * emacs-lisp/eieio-core.el: Prefer inlinable functions over macros.
        (class-p, generic-p, eieio-object-p, class-abstract-p):
        Make them defsubst, so as to avoid corner case problems where
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index d6163f2..e0cdd33 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -3820,6 +3820,10 @@ that suppresses all warnings during execution of BODY."
         ;; If things not being bound at all is ok, so must them being
         ;; obsolete.  Note that we add to the existing lists since Tramp
         ;; (ab)uses this feature.
+         ;; FIXME: If `foo' is obsoleted by `bar', the code below
+         ;; correctly arranges to silence the warnings after testing
+         ;; existence of `foo', but the warning should also be
+         ;; silenced after testing the existence of `bar'.
         (let ((byte-compile-not-obsolete-vars
                (append byte-compile-not-obsolete-vars bound-list))
               (byte-compile-not-obsolete-funcs
diff --git a/lisp/fringe.el b/lisp/fringe.el
index ff60804..97a0393 100644
--- a/lisp/fringe.el
+++ b/lisp/fringe.el
@@ -83,7 +83,7 @@
                  (hollow-small . hollow-square))))
 
 
-(defmacro fringe-bitmap-p (symbol)
+(defun fringe-bitmap-p (symbol)
   "Return non-nil if SYMBOL is a fringe bitmap."
   `(get ,symbol 'fringe))
 
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index a2a122c..e23fd0b 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -412,25 +412,25 @@ size, and full-buffer size."
           (cdr (assq 'color shr-stylesheet))
           (cdr (assq 'background-color shr-stylesheet))))))))
 
-(defmacro shr-char-breakable-p (char)
+(define-inline shr-char-breakable-p (char)
   "Return non-nil if a line can be broken before and after CHAR."
-  `(aref fill-find-break-point-function-table ,char))
-(defmacro shr-char-nospace-p (char)
+  (inline-quote (aref fill-find-break-point-function-table ,char)))
+(define-inline shr-char-nospace-p (char)
   "Return non-nil if no space is required before and after CHAR."
-  `(aref fill-nospace-between-words-table ,char))
+  (inline-quote (aref fill-nospace-between-words-table ,char)))
 
 ;; KINSOKU is a Japanese word meaning a rule that should not be violated.
 ;; In Emacs, it is a term used for characters, e.g. punctuation marks,
 ;; parentheses, and so on, that should not be placed in the beginning
 ;; of a line or the end of a line.
-(defmacro shr-char-kinsoku-bol-p (char)
+(define-inline shr-char-kinsoku-bol-p (char)
   "Return non-nil if a line ought not to begin with CHAR."
-  `(let ((char ,char))
-     (and (not (eq char ?'))
-         (aref (char-category-set char) ?>))))
-(defmacro shr-char-kinsoku-eol-p (char)
+  (inline-letevals (char)
+    (inline-quote (and (not (eq ,char ?'))
+                       (aref (char-category-set ,char) ?>)))))
+(define-inline shr-char-kinsoku-eol-p (char)
   "Return non-nil if a line ought not to end with CHAR."
-  `(aref (char-category-set ,char) ?<))
+  (inline-quote (aref (char-category-set ,char) ?<)))
 (unless (shr-char-kinsoku-bol-p (make-char 'japanese-jisx0208 33 35))
   (load "kinsoku" nil t))
 
diff --git a/lisp/tooltip.el b/lisp/tooltip.el
index 26cce41..973e74b 100644
--- a/lisp/tooltip.el
+++ b/lisp/tooltip.el
@@ -284,10 +284,6 @@ is based on the current syntax table."
        (when (> (point) start)
          (buffer-substring start (point)))))))
 
-(defmacro tooltip-region-active-p ()
-  "Value is non-nil if the region should override command actions."
-  `(use-region-p))
-
 (defun tooltip-expr-to-print (event)
   "Return an expression that should be printed for EVENT.
 If a region is active and the mouse is inside the region, print
@@ -295,7 +291,7 @@ the region.  Otherwise, figure out the identifier around 
the point
 where the mouse is."
   (with-current-buffer (tooltip-event-buffer event)
     (let ((point (posn-point (event-end event))))
-      (if (tooltip-region-active-p)
+      (if (use-region-p)
          (when (and (<= (region-beginning) point) (<= point (region-end)))
            (buffer-substring (region-beginning) (region-end)))
        (tooltip-identifier-from-point point)))))
diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog
index 7ba9de0..18fc2a1 100644
--- a/lisp/url/ChangeLog
+++ b/lisp/url/ChangeLog
@@ -1,3 +1,9 @@
+2014-12-05  Stefan Monnier  <address@hidden>
+
+       * url-future.el (url-future-done-p, url-future-completed-p)
+       (url-future-errored-p, url-future-cancelled-p):
+       * url-dav.el (url-dav-http-success-p): Use define-inline.
+
 2014-11-23  Lars Magne Ingebrigtsen  <address@hidden>
 
        * url-http.el (url-http): Respect `url-request-noninteractive'.
diff --git a/lisp/url/url-dav.el b/lisp/url/url-dav.el
index 6adb2d9..24b20ab 100644
--- a/lisp/url/url-dav.el
+++ b/lisp/url/url-dav.el
@@ -479,9 +479,9 @@ names (ie: DAV:resourcetype)."
                     "  <DAV:allprop/>")
                   depth nil namespaces))
 
-(defmacro url-dav-http-success-p (status)
+(define-inline url-dav-http-success-p (status)
   "Return whether STATUS was the result of a successful DAV request."
-  `(= (/ (or ,status 500) 100) 2))
+  (inline-quote (= (/ (or ,status 500) 100) 2)))
 
 
 ;;; Locking support
diff --git a/lisp/url/url-future.el b/lisp/url/url-future.el
index 0505218..490e6f7 100644
--- a/lisp/url/url-future.el
+++ b/lisp/url/url-future.el
@@ -44,17 +44,17 @@
 
 (cl-defstruct url-future callback errorback status value)
 
-(defmacro url-future-done-p (url-future)
-  `(url-future-status ,url-future))
+(define-inline url-future-done-p (url-future)
+  (inline-quote (url-future-status ,url-future)))
 
-(defmacro url-future-completed-p (url-future)
-  `(eq (url-future-status ,url-future) t))
+(define-inline url-future-completed-p (url-future)
+  (inline-quote (eq (url-future-status ,url-future) t)))
 
-(defmacro url-future-errored-p (url-future)
-  `(eq (url-future-status ,url-future) 'error))
+(define-inline url-future-errored-p (url-future)
+  (inline-quote (eq (url-future-status ,url-future) 'error)))
 
-(defmacro url-future-cancelled-p (url-future)
-  `(eq (url-future-status ,url-future) 'cancel))
+(define-inline url-future-cancelled-p (url-future)
+  (inline-quote (eq (url-future-status ,url-future) 'cancel)))
 
 (defun url-future-finish (url-future &optional status)
   (if (url-future-done-p url-future)
diff --git a/lisp/vc/ediff-init.el b/lisp/vc/ediff-init.el
index 589ea45..9669e2c 100644
--- a/lisp/vc/ediff-init.el
+++ b/lisp/vc/ediff-init.el
@@ -24,6 +24,8 @@
 
 ;;; Code:
 
+(require 'cl-lib)
+
 ;; Start compiler pacifier
 (defvar ediff-metajob-name)
 (defvar ediff-meta-buffer)
@@ -118,11 +120,8 @@ It needs to be killed when we quit the session.")
     (?C . ediff-buffer-C)))
 
 ;;; Macros
-(defmacro ediff-odd-p (arg)
-  `(eq (logand ,arg 1) 1))
-
-(defmacro ediff-buffer-live-p (buf)
-  `(and ,buf (get-buffer ,buf) (buffer-name (get-buffer ,buf))))
+(defsubst ediff-buffer-live-p (buf)
+  (and buf (get-buffer buf) (buffer-name (get-buffer buf))))
 
 (defmacro ediff-get-buffer (arg)
   `(cond ((eq ,arg 'A) ediff-buffer-A)
@@ -1456,7 +1455,7 @@ This default should work without changes."
   ;; The value of dif-num is always 1- the one that user sees.
   ;; This is why even face is used when dif-num is odd.
   (ediff-get-symbol-from-alist
-   buf-type (if (ediff-odd-p dif-num)
+   buf-type (if (cl-oddp dif-num)
                ediff-even-diff-face-alist
              ediff-odd-diff-face-alist)
    ))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]