aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorStefan Monnier2014-12-05 12:13:09 -0500
committerStefan Monnier2014-12-05 12:13:09 -0500
commit887fa622851c7db45ccacedb1c88e13e27be5d26 (patch)
tree2166b779b8d0c15ea8cecaaa0a3a9005b2a89a3c /lisp
parent2a06fc15b2a3e6287f18025806fb2eabec801fc0 (diff)
downloademacs-887fa622851c7db45ccacedb1c88e13e27be5d26.tar.gz
emacs-887fa622851c7db45ccacedb1c88e13e27be5d26.zip
* lisp/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 the arg might be evaluated in the condition-case, or it can't be passed to higher-order functions like `cl-some'.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/emacs-lisp/eieio-core.el31
2 files changed, 23 insertions, 16 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 72adfb1f467..54e0804e4f4 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12014-12-05 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * emacs-lisp/eieio-core.el: Prefer inlinable functions over macros.
4 (class-p, generic-p, eieio-object-p, class-abstract-p):
5 Make them defsubst, so as to avoid corner case problems where
6 the arg might be evaluated in the condition-case, or it can't be passed
7 to higher-order functions like `cl-some'.
8
12014-12-05 Nicolas Richard <theonewiththeevillook@yahoo.fr> 92014-12-05 Nicolas Richard <theonewiththeevillook@yahoo.fr>
2 10
3 * wid-edit.el (widget-choose): Let numeric keypad work (bug#19268) 11 * wid-edit.el (widget-choose): Let numeric keypad work (bug#19268)
diff --git a/lisp/emacs-lisp/eieio-core.el b/lisp/emacs-lisp/eieio-core.el
index 4aae9900f11..2897ce9042a 100644
--- a/lisp/emacs-lisp/eieio-core.el
+++ b/lisp/emacs-lisp/eieio-core.el
@@ -206,14 +206,14 @@ Stored outright without modifications or stripping.")))
206 ;; No check: If eieio gets this far, it has probably been checked already. 206 ;; No check: If eieio gets this far, it has probably been checked already.
207 `(get ,class 'eieio-class-definition)) 207 `(get ,class 'eieio-class-definition))
208 208
209(defmacro class-p (class) 209(defsubst class-p (class)
210 "Return t if CLASS is a valid class vector. 210 "Return non-nil if CLASS is a valid class vector.
211CLASS is a symbol." 211CLASS is a symbol."
212 ;; this new method is faster since it doesn't waste time checking lots of 212 ;; this new method is faster since it doesn't waste time checking lots of
213 ;; things. 213 ;; things.
214 `(condition-case nil 214 (condition-case nil
215 (eq (aref (class-v ,class) 0) 'defclass) 215 (eq (aref (class-v class) 0) 'defclass)
216 (error nil))) 216 (error nil)))
217 217
218(defun eieio-class-name (class) "Return a Lisp like symbol name for CLASS." 218(defun eieio-class-name (class) "Return a Lisp like symbol name for CLASS."
219 (eieio--check-type class-p class) 219 (eieio--check-type class-p class)
@@ -237,11 +237,11 @@ CLASS is a symbol."
237 "Return the symbol representing the constructor of CLASS." 237 "Return the symbol representing the constructor of CLASS."
238 `(eieio--class-symbol (class-v ,class))) 238 `(eieio--class-symbol (class-v ,class)))
239 239
240(defmacro generic-p (method) 240(defsubst generic-p (method)
241 "Return t if symbol METHOD is a generic function. 241 "Return non-nil if symbol METHOD is a generic function.
242Only methods have the symbol `eieio-method-obarray' as a property 242Only methods have the symbol `eieio-method-obarray' as a property
243\(which contains a list of all bindings to that method type.)" 243\(which contains a list of all bindings to that method type.)"
244 `(and (fboundp ,method) (get ,method 'eieio-method-obarray))) 244 (and (fboundp method) (get method 'eieio-method-obarray)))
245 245
246(defun generic-primary-only-p (method) 246(defun generic-primary-only-p (method)
247 "Return t if symbol METHOD is a generic function with only primary methods. 247 "Return t if symbol METHOD is a generic function with only primary methods.
@@ -284,19 +284,18 @@ Methods with only primary implementations are executed in an optimized way."
284Return nil if that option doesn't exist." 284Return nil if that option doesn't exist."
285 `(class-option-assoc (eieio--class-options (class-v ,class)) ',option)) 285 `(class-option-assoc (eieio--class-options (class-v ,class)) ',option))
286 286
287(defmacro eieio-object-p (obj) 287(defsubst eieio-object-p (obj)
288 "Return non-nil if OBJ is an EIEIO object." 288 "Return non-nil if OBJ is an EIEIO object."
289 `(condition-case nil 289 (condition-case nil
290 (let ((tobj ,obj)) 290 (and (eq (aref obj 0) 'object)
291 (and (eq (aref tobj 0) 'object) 291 (class-p (eieio--object-class obj)))
292 (class-p (eieio--object-class tobj)))) 292 (error nil)))
293 (error nil)))
294(defalias 'object-p 'eieio-object-p) 293(defalias 'object-p 'eieio-object-p)
295 294
296(defmacro class-abstract-p (class) 295(defsubst class-abstract-p (class)
297 "Return non-nil if CLASS is abstract. 296 "Return non-nil if CLASS is abstract.
298Abstract classes cannot be instantiated." 297Abstract classes cannot be instantiated."
299 `(class-option ,class :abstract)) 298 (class-option class :abstract))
300 299
301(defmacro class-method-invocation-order (class) 300(defmacro class-method-invocation-order (class)
302 "Return the invocation order of CLASS. 301 "Return the invocation order of CLASS.