diff options
| author | Paul Eggert | 2016-12-06 21:38:32 -0800 |
|---|---|---|
| committer | Paul Eggert | 2016-12-06 21:40:38 -0800 |
| commit | f0870da2bb5eee848a5561fb58b2ec3a63861052 (patch) | |
| tree | 04e35afb3918dd711508b706520dedf342e929e7 /src | |
| parent | 2a3420d94206a97f094580e06c25af91d5949516 (diff) | |
| download | emacs-f0870da2bb5eee848a5561fb58b2ec3a63861052.tar.gz emacs-f0870da2bb5eee848a5561fb58b2ec3a63861052.zip | |
Simplify FUNCTIONP implementation
* src/bytecode.c (exec_byte_code):
* src/image.c (parse_image_spec):
Prefer FUNCTIONP (x) to !NILP (Ffunctionp (x)).
* src/eval.c (FUNCTIONP): Move here ...
* src/lisp.h: ... from here. No longer inline, as that
bloats the text and does not help speed (at least on my platform).
(functionp): Remove this name, since callers use FUNCTIONP.
Diffstat (limited to 'src')
| -rw-r--r-- | src/bytecode.c | 3 | ||||
| -rw-r--r-- | src/dbusbind.c | 2 | ||||
| -rw-r--r-- | src/eval.c | 31 | ||||
| -rw-r--r-- | src/image.c | 2 | ||||
| -rw-r--r-- | src/lisp.h | 41 | ||||
| -rw-r--r-- | src/xwidget.c | 2 |
6 files changed, 36 insertions, 45 deletions
diff --git a/src/bytecode.c b/src/bytecode.c index 868c0148d30..71ecdbf2cc0 100644 --- a/src/bytecode.c +++ b/src/bytecode.c | |||
| @@ -809,8 +809,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, | |||
| 809 | { | 809 | { |
| 810 | Lisp_Object handler = POP; | 810 | Lisp_Object handler = POP; |
| 811 | /* Support for a function here is new in 24.4. */ | 811 | /* Support for a function here is new in 24.4. */ |
| 812 | record_unwind_protect ((NILP (Ffunctionp (handler)) | 812 | record_unwind_protect (FUNCTIONP (handler) ? bcall0 : unwind_body, |
| 813 | ? unwind_body : bcall0), | ||
| 814 | handler); | 813 | handler); |
| 815 | NEXT; | 814 | NEXT; |
| 816 | } | 815 | } |
diff --git a/src/dbusbind.c b/src/dbusbind.c index a0146a3bf53..23392d8dcc3 100644 --- a/src/dbusbind.c +++ b/src/dbusbind.c | |||
| @@ -1309,7 +1309,7 @@ usage: (dbus-message-internal &rest REST) */) | |||
| 1309 | XD_DBUS_VALIDATE_PATH (path); | 1309 | XD_DBUS_VALIDATE_PATH (path); |
| 1310 | XD_DBUS_VALIDATE_INTERFACE (interface); | 1310 | XD_DBUS_VALIDATE_INTERFACE (interface); |
| 1311 | XD_DBUS_VALIDATE_MEMBER (member); | 1311 | XD_DBUS_VALIDATE_MEMBER (member); |
| 1312 | if (!NILP (handler) && (!FUNCTIONP (handler))) | 1312 | if (!NILP (handler) && !FUNCTIONP (handler)) |
| 1313 | wrong_type_argument (Qinvalid_function, handler); | 1313 | wrong_type_argument (Qinvalid_function, handler); |
| 1314 | } | 1314 | } |
| 1315 | 1315 | ||
diff --git a/src/eval.c b/src/eval.c index 724f0018a58..8ad06dded80 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -2638,6 +2638,37 @@ DEFUN ("functionp", Ffunctionp, Sfunctionp, 1, 1, 0, | |||
| 2638 | return Qnil; | 2638 | return Qnil; |
| 2639 | } | 2639 | } |
| 2640 | 2640 | ||
| 2641 | bool | ||
| 2642 | FUNCTIONP (Lisp_Object object) | ||
| 2643 | { | ||
| 2644 | if (SYMBOLP (object) && !NILP (Ffboundp (object))) | ||
| 2645 | { | ||
| 2646 | object = Findirect_function (object, Qt); | ||
| 2647 | |||
| 2648 | if (CONSP (object) && EQ (XCAR (object), Qautoload)) | ||
| 2649 | { | ||
| 2650 | /* Autoloaded symbols are functions, except if they load | ||
| 2651 | macros or keymaps. */ | ||
| 2652 | for (int i = 0; i < 4 && CONSP (object); i++) | ||
| 2653 | object = XCDR (object); | ||
| 2654 | |||
| 2655 | return ! (CONSP (object) && !NILP (XCAR (object))); | ||
| 2656 | } | ||
| 2657 | } | ||
| 2658 | |||
| 2659 | if (SUBRP (object)) | ||
| 2660 | return XSUBR (object)->max_args != UNEVALLED; | ||
| 2661 | else if (COMPILEDP (object)) | ||
| 2662 | return true; | ||
| 2663 | else if (CONSP (object)) | ||
| 2664 | { | ||
| 2665 | Lisp_Object car = XCAR (object); | ||
| 2666 | return EQ (car, Qlambda) || EQ (car, Qclosure); | ||
| 2667 | } | ||
| 2668 | else | ||
| 2669 | return false; | ||
| 2670 | } | ||
| 2671 | |||
| 2641 | DEFUN ("funcall", Ffuncall, Sfuncall, 1, MANY, 0, | 2672 | DEFUN ("funcall", Ffuncall, Sfuncall, 1, MANY, 0, |
| 2642 | doc: /* Call first argument as a function, passing remaining arguments to it. | 2673 | doc: /* Call first argument as a function, passing remaining arguments to it. |
| 2643 | Return the value that function returns. | 2674 | Return the value that function returns. |
diff --git a/src/image.c b/src/image.c index a87dc4d4737..89572b87647 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -793,7 +793,7 @@ parse_image_spec (Lisp_Object spec, struct image_keyword *keywords, | |||
| 793 | 793 | ||
| 794 | case IMAGE_FUNCTION_VALUE: | 794 | case IMAGE_FUNCTION_VALUE: |
| 795 | value = indirect_function (value); | 795 | value = indirect_function (value); |
| 796 | if (!NILP (Ffunctionp (value))) | 796 | if (FUNCTIONP (value)) |
| 797 | break; | 797 | break; |
| 798 | return 0; | 798 | return 0; |
| 799 | 799 | ||
diff --git a/src/lisp.h b/src/lisp.h index 3d39dc40dc2..b9c6289edef 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -564,7 +564,6 @@ INLINE bool CHAR_TABLE_P (Lisp_Object); | |||
| 564 | INLINE Lisp_Object CHAR_TABLE_REF_ASCII (Lisp_Object, ptrdiff_t); | 564 | INLINE Lisp_Object CHAR_TABLE_REF_ASCII (Lisp_Object, ptrdiff_t); |
| 565 | INLINE bool (CONSP) (Lisp_Object); | 565 | INLINE bool (CONSP) (Lisp_Object); |
| 566 | INLINE bool (FLOATP) (Lisp_Object); | 566 | INLINE bool (FLOATP) (Lisp_Object); |
| 567 | INLINE bool functionp (Lisp_Object); | ||
| 568 | INLINE bool (INTEGERP) (Lisp_Object); | 567 | INLINE bool (INTEGERP) (Lisp_Object); |
| 569 | INLINE bool (MARKERP) (Lisp_Object); | 568 | INLINE bool (MARKERP) (Lisp_Object); |
| 570 | INLINE bool (MISCP) (Lisp_Object); | 569 | INLINE bool (MISCP) (Lisp_Object); |
| @@ -2994,13 +2993,6 @@ CHECK_NUMBER_CDR (Lisp_Object x) | |||
| 2994 | Lisp_Object fnname | 2993 | Lisp_Object fnname |
| 2995 | #endif | 2994 | #endif |
| 2996 | 2995 | ||
| 2997 | /* True if OBJ is a Lisp function. */ | ||
| 2998 | INLINE bool | ||
| 2999 | FUNCTIONP (Lisp_Object obj) | ||
| 3000 | { | ||
| 3001 | return functionp (obj); | ||
| 3002 | } | ||
| 3003 | |||
| 3004 | /* defsubr (Sname); | 2996 | /* defsubr (Sname); |
| 3005 | is how we define the symbol for function `name' at start-up time. */ | 2997 | is how we define the symbol for function `name' at start-up time. */ |
| 3006 | extern void defsubr (struct Lisp_Subr *); | 2998 | extern void defsubr (struct Lisp_Subr *); |
| @@ -3915,6 +3907,7 @@ extern _Noreturn void xsignal2 (Lisp_Object, Lisp_Object, Lisp_Object); | |||
| 3915 | extern _Noreturn void xsignal3 (Lisp_Object, Lisp_Object, Lisp_Object, | 3907 | extern _Noreturn void xsignal3 (Lisp_Object, Lisp_Object, Lisp_Object, |
| 3916 | Lisp_Object); | 3908 | Lisp_Object); |
| 3917 | extern _Noreturn void signal_error (const char *, Lisp_Object); | 3909 | extern _Noreturn void signal_error (const char *, Lisp_Object); |
| 3910 | extern bool FUNCTIONP (Lisp_Object); | ||
| 3918 | extern Lisp_Object funcall_subr (struct Lisp_Subr *subr, ptrdiff_t numargs, Lisp_Object *arg_vector); | 3911 | extern Lisp_Object funcall_subr (struct Lisp_Subr *subr, ptrdiff_t numargs, Lisp_Object *arg_vector); |
| 3919 | extern Lisp_Object eval_sub (Lisp_Object form); | 3912 | extern Lisp_Object eval_sub (Lisp_Object form); |
| 3920 | extern Lisp_Object apply1 (Lisp_Object, Lisp_Object); | 3913 | extern Lisp_Object apply1 (Lisp_Object, Lisp_Object); |
| @@ -4722,38 +4715,6 @@ maybe_gc (void) | |||
| 4722 | Fgarbage_collect (); | 4715 | Fgarbage_collect (); |
| 4723 | } | 4716 | } |
| 4724 | 4717 | ||
| 4725 | INLINE bool | ||
| 4726 | functionp (Lisp_Object object) | ||
| 4727 | { | ||
| 4728 | if (SYMBOLP (object) && !NILP (Ffboundp (object))) | ||
| 4729 | { | ||
| 4730 | object = Findirect_function (object, Qt); | ||
| 4731 | |||
| 4732 | if (CONSP (object) && EQ (XCAR (object), Qautoload)) | ||
| 4733 | { | ||
| 4734 | /* Autoloaded symbols are functions, except if they load | ||
| 4735 | macros or keymaps. */ | ||
| 4736 | int i; | ||
| 4737 | for (i = 0; i < 4 && CONSP (object); i++) | ||
| 4738 | object = XCDR (object); | ||
| 4739 | |||
| 4740 | return ! (CONSP (object) && !NILP (XCAR (object))); | ||
| 4741 | } | ||
| 4742 | } | ||
| 4743 | |||
| 4744 | if (SUBRP (object)) | ||
| 4745 | return XSUBR (object)->max_args != UNEVALLED; | ||
| 4746 | else if (COMPILEDP (object)) | ||
| 4747 | return true; | ||
| 4748 | else if (CONSP (object)) | ||
| 4749 | { | ||
| 4750 | Lisp_Object car = XCAR (object); | ||
| 4751 | return EQ (car, Qlambda) || EQ (car, Qclosure); | ||
| 4752 | } | ||
| 4753 | else | ||
| 4754 | return false; | ||
| 4755 | } | ||
| 4756 | |||
| 4757 | INLINE_HEADER_END | 4718 | INLINE_HEADER_END |
| 4758 | 4719 | ||
| 4759 | #endif /* EMACS_LISP_H */ | 4720 | #endif /* EMACS_LISP_H */ |
diff --git a/src/xwidget.c b/src/xwidget.c index d1f9540e11f..62df6657e9f 100644 --- a/src/xwidget.c +++ b/src/xwidget.c | |||
| @@ -711,7 +711,7 @@ argument procedure FUN.*/) | |||
| 711 | { | 711 | { |
| 712 | WEBKIT_FN_INIT (); | 712 | WEBKIT_FN_INIT (); |
| 713 | CHECK_STRING (script); | 713 | CHECK_STRING (script); |
| 714 | if (!NILP (fun) && (!FUNCTIONP (fun))) | 714 | if (!NILP (fun) && !FUNCTIONP (fun)) |
| 715 | wrong_type_argument (Qinvalid_function, fun); | 715 | wrong_type_argument (Qinvalid_function, fun); |
| 716 | 716 | ||
| 717 | void *callback = (FUNCTIONP (fun)) ? | 717 | void *callback = (FUNCTIONP (fun)) ? |