summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@Penguin.CS.UCLA.EDU>2016-12-06 21:38:32 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2016-12-06 21:40:38 -0800
commitf0870da2bb5eee848a5561fb58b2ec3a63861052 (patch)
tree04e35afb3918dd711508b706520dedf342e929e7 /src
parent2a3420d94206a97f094580e06c25af91d5949516 (diff)
downloademacs-f0870da2bb5eee848a5561fb58b2ec3a63861052.tar.gz
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.c3
-rw-r--r--src/dbusbind.c2
-rw-r--r--src/eval.c31
-rw-r--r--src/image.c2
-rw-r--r--src/lisp.h41
-rw-r--r--src/xwidget.c2
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,
{
Lisp_Object handler = POP;
/* Support for a function here is new in 24.4. */
- record_unwind_protect ((NILP (Ffunctionp (handler))
- ? unwind_body : bcall0),
+ record_unwind_protect (FUNCTIONP (handler) ? bcall0 : unwind_body,
handler);
NEXT;
}
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) */)
XD_DBUS_VALIDATE_PATH (path);
XD_DBUS_VALIDATE_INTERFACE (interface);
XD_DBUS_VALIDATE_MEMBER (member);
- if (!NILP (handler) && (!FUNCTIONP (handler)))
+ if (!NILP (handler) && !FUNCTIONP (handler))
wrong_type_argument (Qinvalid_function, handler);
}
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,
return Qnil;
}
+bool
+FUNCTIONP (Lisp_Object object)
+{
+ if (SYMBOLP (object) && !NILP (Ffboundp (object)))
+ {
+ object = Findirect_function (object, Qt);
+
+ if (CONSP (object) && EQ (XCAR (object), Qautoload))
+ {
+ /* Autoloaded symbols are functions, except if they load
+ macros or keymaps. */
+ for (int i = 0; i < 4 && CONSP (object); i++)
+ object = XCDR (object);
+
+ return ! (CONSP (object) && !NILP (XCAR (object)));
+ }
+ }
+
+ if (SUBRP (object))
+ return XSUBR (object)->max_args != UNEVALLED;
+ else if (COMPILEDP (object))
+ return true;
+ else if (CONSP (object))
+ {
+ Lisp_Object car = XCAR (object);
+ return EQ (car, Qlambda) || EQ (car, Qclosure);
+ }
+ else
+ return false;
+}
+
DEFUN ("funcall", Ffuncall, Sfuncall, 1, MANY, 0,
doc: /* Call first argument as a function, passing remaining arguments to it.
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,
case IMAGE_FUNCTION_VALUE:
value = indirect_function (value);
- if (!NILP (Ffunctionp (value)))
+ if (FUNCTIONP (value))
break;
return 0;
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);
INLINE Lisp_Object CHAR_TABLE_REF_ASCII (Lisp_Object, ptrdiff_t);
INLINE bool (CONSP) (Lisp_Object);
INLINE bool (FLOATP) (Lisp_Object);
-INLINE bool functionp (Lisp_Object);
INLINE bool (INTEGERP) (Lisp_Object);
INLINE bool (MARKERP) (Lisp_Object);
INLINE bool (MISCP) (Lisp_Object);
@@ -2994,13 +2993,6 @@ CHECK_NUMBER_CDR (Lisp_Object x)
Lisp_Object fnname
#endif
-/* True if OBJ is a Lisp function. */
-INLINE bool
-FUNCTIONP (Lisp_Object obj)
-{
- return functionp (obj);
-}
-
/* defsubr (Sname);
is how we define the symbol for function `name' at start-up time. */
extern void defsubr (struct Lisp_Subr *);
@@ -3915,6 +3907,7 @@ extern _Noreturn void xsignal2 (Lisp_Object, Lisp_Object, Lisp_Object);
extern _Noreturn void xsignal3 (Lisp_Object, Lisp_Object, Lisp_Object,
Lisp_Object);
extern _Noreturn void signal_error (const char *, Lisp_Object);
+extern bool FUNCTIONP (Lisp_Object);
extern Lisp_Object funcall_subr (struct Lisp_Subr *subr, ptrdiff_t numargs, Lisp_Object *arg_vector);
extern Lisp_Object eval_sub (Lisp_Object form);
extern Lisp_Object apply1 (Lisp_Object, Lisp_Object);
@@ -4722,38 +4715,6 @@ maybe_gc (void)
Fgarbage_collect ();
}
-INLINE bool
-functionp (Lisp_Object object)
-{
- if (SYMBOLP (object) && !NILP (Ffboundp (object)))
- {
- object = Findirect_function (object, Qt);
-
- if (CONSP (object) && EQ (XCAR (object), Qautoload))
- {
- /* Autoloaded symbols are functions, except if they load
- macros or keymaps. */
- int i;
- for (i = 0; i < 4 && CONSP (object); i++)
- object = XCDR (object);
-
- return ! (CONSP (object) && !NILP (XCAR (object)));
- }
- }
-
- if (SUBRP (object))
- return XSUBR (object)->max_args != UNEVALLED;
- else if (COMPILEDP (object))
- return true;
- else if (CONSP (object))
- {
- Lisp_Object car = XCAR (object);
- return EQ (car, Qlambda) || EQ (car, Qclosure);
- }
- else
- return false;
-}
-
INLINE_HEADER_END
#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.*/)
{
WEBKIT_FN_INIT ();
CHECK_STRING (script);
- if (!NILP (fun) && (!FUNCTIONP (fun)))
+ if (!NILP (fun) && !FUNCTIONP (fun))
wrong_type_argument (Qinvalid_function, fun);
void *callback = (FUNCTIONP (fun)) ?