aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias EngdegÄrd2022-03-21 11:20:37 +0100
committerMattias EngdegÄrd2022-04-04 09:49:31 +0200
commitf365607bc059169e5aa9f98c8418661d6fc6477d (patch)
tree314277594e4d2eed8c9deb3ffd0cfe67820cf45e /src
parent530f163a7f4f1f0ead119b8d3c3dd9fa882af9b2 (diff)
downloademacs-f365607bc059169e5aa9f98c8418661d6fc6477d.tar.gz
emacs-f365607bc059169e5aa9f98c8418661d6fc6477d.zip
Inline call0..8
Inlining these trivial functions gives a healthy speed boost to many common functions such as `sort`, `mapcar` etc. * src/eval.c (call0, ..., call8): Move functions... * src/lisp.h (call0, ..., call8): ...here and declare them inline.
Diffstat (limited to 'src')
-rw-r--r--src/eval.c70
-rw-r--r--src/lisp.h79
2 files changed, 70 insertions, 79 deletions
diff --git a/src/eval.c b/src/eval.c
index 7269582333c..a1cebcd0257 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -2766,76 +2766,6 @@ apply1 (Lisp_Object fn, Lisp_Object arg)
2766 return NILP (arg) ? Ffuncall (1, &fn) : CALLN (Fapply, fn, arg); 2766 return NILP (arg) ? Ffuncall (1, &fn) : CALLN (Fapply, fn, arg);
2767} 2767}
2768 2768
2769/* Call function fn on no arguments. */
2770Lisp_Object
2771call0 (Lisp_Object fn)
2772{
2773 return Ffuncall (1, &fn);
2774}
2775
2776/* Call function fn with 1 argument arg1. */
2777Lisp_Object
2778call1 (Lisp_Object fn, Lisp_Object arg1)
2779{
2780 return CALLN (Ffuncall, fn, arg1);
2781}
2782
2783/* Call function fn with 2 arguments arg1, arg2. */
2784Lisp_Object
2785call2 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2)
2786{
2787 return CALLN (Ffuncall, fn, arg1, arg2);
2788}
2789
2790/* Call function fn with 3 arguments arg1, arg2, arg3. */
2791Lisp_Object
2792call3 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3)
2793{
2794 return CALLN (Ffuncall, fn, arg1, arg2, arg3);
2795}
2796
2797/* Call function fn with 4 arguments arg1, arg2, arg3, arg4. */
2798Lisp_Object
2799call4 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3,
2800 Lisp_Object arg4)
2801{
2802 return CALLN (Ffuncall, fn, arg1, arg2, arg3, arg4);
2803}
2804
2805/* Call function fn with 5 arguments arg1, arg2, arg3, arg4, arg5. */
2806Lisp_Object
2807call5 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3,
2808 Lisp_Object arg4, Lisp_Object arg5)
2809{
2810 return CALLN (Ffuncall, fn, arg1, arg2, arg3, arg4, arg5);
2811}
2812
2813/* Call function fn with 6 arguments arg1, arg2, arg3, arg4, arg5, arg6. */
2814Lisp_Object
2815call6 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3,
2816 Lisp_Object arg4, Lisp_Object arg5, Lisp_Object arg6)
2817{
2818 return CALLN (Ffuncall, fn, arg1, arg2, arg3, arg4, arg5, arg6);
2819}
2820
2821/* Call function fn with 7 arguments arg1, arg2, arg3, arg4, arg5, arg6, arg7. */
2822Lisp_Object
2823call7 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3,
2824 Lisp_Object arg4, Lisp_Object arg5, Lisp_Object arg6, Lisp_Object arg7)
2825{
2826 return CALLN (Ffuncall, fn, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
2827}
2828
2829/* Call function fn with 8 arguments arg1, arg2, arg3, arg4, arg5,
2830 arg6, arg7, arg8. */
2831Lisp_Object
2832call8 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3,
2833 Lisp_Object arg4, Lisp_Object arg5, Lisp_Object arg6, Lisp_Object arg7,
2834 Lisp_Object arg8)
2835{
2836 return CALLN (Ffuncall, fn, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
2837}
2838
2839DEFUN ("functionp", Ffunctionp, Sfunctionp, 1, 1, 0, 2769DEFUN ("functionp", Ffunctionp, Sfunctionp, 1, 1, 0,
2840 doc: /* Return t if OBJECT is a function. */) 2770 doc: /* Return t if OBJECT is a function. */)
2841 (Lisp_Object object) 2771 (Lisp_Object object)
diff --git a/src/lisp.h b/src/lisp.h
index 179c09702ca..9c7dc3bc6fc 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3202,6 +3202,76 @@ enum maxargs
3202 'Finsert (1, &text);'. */ 3202 'Finsert (1, &text);'. */
3203#define CALLN(f, ...) CALLMANY (f, ((Lisp_Object []) {__VA_ARGS__})) 3203#define CALLN(f, ...) CALLMANY (f, ((Lisp_Object []) {__VA_ARGS__}))
3204 3204
3205/* Call function fn on no arguments. */
3206INLINE Lisp_Object
3207call0 (Lisp_Object fn)
3208{
3209 return Ffuncall (1, &fn);
3210}
3211
3212/* Call function fn with 1 argument arg1. */
3213INLINE Lisp_Object
3214call1 (Lisp_Object fn, Lisp_Object arg1)
3215{
3216 return CALLN (Ffuncall, fn, arg1);
3217}
3218
3219/* Call function fn with 2 arguments arg1, arg2. */
3220INLINE Lisp_Object
3221call2 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2)
3222{
3223 return CALLN (Ffuncall, fn, arg1, arg2);
3224}
3225
3226/* Call function fn with 3 arguments arg1, arg2, arg3. */
3227INLINE Lisp_Object
3228call3 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3)
3229{
3230 return CALLN (Ffuncall, fn, arg1, arg2, arg3);
3231}
3232
3233/* Call function fn with 4 arguments arg1, arg2, arg3, arg4. */
3234INLINE Lisp_Object
3235call4 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3,
3236 Lisp_Object arg4)
3237{
3238 return CALLN (Ffuncall, fn, arg1, arg2, arg3, arg4);
3239}
3240
3241/* Call function fn with 5 arguments arg1, arg2, arg3, arg4, arg5. */
3242INLINE Lisp_Object
3243call5 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3,
3244 Lisp_Object arg4, Lisp_Object arg5)
3245{
3246 return CALLN (Ffuncall, fn, arg1, arg2, arg3, arg4, arg5);
3247}
3248
3249/* Call function fn with 6 arguments arg1, arg2, arg3, arg4, arg5, arg6. */
3250INLINE Lisp_Object
3251call6 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3,
3252 Lisp_Object arg4, Lisp_Object arg5, Lisp_Object arg6)
3253{
3254 return CALLN (Ffuncall, fn, arg1, arg2, arg3, arg4, arg5, arg6);
3255}
3256
3257/* Call function fn with 7 arguments arg1, arg2, arg3, arg4, arg5, arg6, arg7. */
3258INLINE Lisp_Object
3259call7 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3,
3260 Lisp_Object arg4, Lisp_Object arg5, Lisp_Object arg6, Lisp_Object arg7)
3261{
3262 return CALLN (Ffuncall, fn, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
3263}
3264
3265/* Call function fn with 8 arguments arg1, arg2, arg3, arg4, arg5,
3266 arg6, arg7, arg8. */
3267INLINE Lisp_Object
3268call8 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3,
3269 Lisp_Object arg4, Lisp_Object arg5, Lisp_Object arg6, Lisp_Object arg7,
3270 Lisp_Object arg8)
3271{
3272 return CALLN (Ffuncall, fn, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
3273}
3274
3205extern void defvar_lisp (struct Lisp_Objfwd const *, char const *); 3275extern void defvar_lisp (struct Lisp_Objfwd const *, char const *);
3206extern void defvar_lisp_nopro (struct Lisp_Objfwd const *, char const *); 3276extern void defvar_lisp_nopro (struct Lisp_Objfwd const *, char const *);
3207extern void defvar_bool (struct Lisp_Boolfwd const *, char const *); 3277extern void defvar_bool (struct Lisp_Boolfwd const *, char const *);
@@ -4453,15 +4523,6 @@ extern bool FUNCTIONP (Lisp_Object);
4453extern Lisp_Object funcall_subr (struct Lisp_Subr *subr, ptrdiff_t numargs, Lisp_Object *arg_vector); 4523extern Lisp_Object funcall_subr (struct Lisp_Subr *subr, ptrdiff_t numargs, Lisp_Object *arg_vector);
4454extern Lisp_Object eval_sub (Lisp_Object form); 4524extern Lisp_Object eval_sub (Lisp_Object form);
4455extern Lisp_Object apply1 (Lisp_Object, Lisp_Object); 4525extern Lisp_Object apply1 (Lisp_Object, Lisp_Object);
4456extern Lisp_Object call0 (Lisp_Object);
4457extern Lisp_Object call1 (Lisp_Object, Lisp_Object);
4458extern Lisp_Object call2 (Lisp_Object, Lisp_Object, Lisp_Object);
4459extern Lisp_Object call3 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object);
4460extern Lisp_Object call4 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object);
4461extern Lisp_Object call5 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object);
4462extern Lisp_Object call6 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object);
4463extern Lisp_Object call7 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object);
4464extern Lisp_Object call8 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object);
4465extern Lisp_Object internal_catch (Lisp_Object, Lisp_Object (*) (Lisp_Object), Lisp_Object); 4526extern Lisp_Object internal_catch (Lisp_Object, Lisp_Object (*) (Lisp_Object), Lisp_Object);
4466extern Lisp_Object internal_lisp_condition_case (Lisp_Object, Lisp_Object, Lisp_Object); 4527extern Lisp_Object internal_lisp_condition_case (Lisp_Object, Lisp_Object, Lisp_Object);
4467extern Lisp_Object internal_condition_case (Lisp_Object (*) (void), Lisp_Object, Lisp_Object (*) (Lisp_Object)); 4528extern Lisp_Object internal_condition_case (Lisp_Object (*) (void), Lisp_Object, Lisp_Object (*) (Lisp_Object));