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.
This commit is contained in:
Paul Eggert 2016-12-06 21:38:32 -08:00 committed by Paul Eggert
parent 2a3420d942
commit f0870da2bb
6 changed files with 36 additions and 45 deletions

View file

@ -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;
}

View file

@ -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);
}

View file

@ -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.

View file

@ -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;

View file

@ -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 */

View file

@ -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)) ?