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:
parent
2a3420d942
commit
f0870da2bb
6 changed files with 36 additions and 45 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
31
src/eval.c
31
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.
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
41
src/lisp.h
41
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 */
|
||||
|
|
|
@ -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)) ?
|
||||
|
|
Loading…
Add table
Reference in a new issue