aboutsummaryrefslogtreecommitdiffstats
path: root/src/keymap.c
diff options
context:
space:
mode:
authorPaul Eggert2018-06-14 15:59:08 -0700
committerPaul Eggert2018-06-14 17:13:38 -0700
commit12fd59bba0b04fb6727f4fa54e3305a65fae1d44 (patch)
treea01a32e9fd01e35f566d97647e79acb43b43f9a3 /src/keymap.c
parentef66660c17d1b164414c46d67ba3494f8a18c8ec (diff)
downloademacs-12fd59bba0b04fb6727f4fa54e3305a65fae1d44.tar.gz
emacs-12fd59bba0b04fb6727f4fa54e3305a65fae1d44.zip
Avoid Lisp_Misc allocation if C stack suffices
* src/fileio.c (union read_non_regular): New type. (read_non_regular, Finsert_file_contents): Use it to avoid allocating a Lisp_Misc. * src/keymap.c (union map_keymap): New type. (map_keymap_char_table_item, map_keymap_internal): Use it to avoid allocating a Lisp_Misc.
Diffstat (limited to 'src/keymap.c')
-rw-r--r--src/keymap.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/keymap.c b/src/keymap.c
index c8cc933e782..982c014f01f 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -546,19 +546,29 @@ map_keymap_item (map_keymap_function_t fun, Lisp_Object args, Lisp_Object key, L
546 (*fun) (key, val, args, data); 546 (*fun) (key, val, args, data);
547} 547}
548 548
549union map_keymap
550{
551 struct
552 {
553 map_keymap_function_t fun;
554 Lisp_Object args;
555 void *data;
556 } s;
557 GCALIGNED_UNION
558};
559verify (alignof (union map_keymap) % GCALIGNMENT == 0);
560
549static void 561static void
550map_keymap_char_table_item (Lisp_Object args, Lisp_Object key, Lisp_Object val) 562map_keymap_char_table_item (Lisp_Object args, Lisp_Object key, Lisp_Object val)
551{ 563{
552 if (!NILP (val)) 564 if (!NILP (val))
553 { 565 {
554 map_keymap_function_t fun
555 = (map_keymap_function_t) XSAVE_FUNCPOINTER (args, 0);
556 /* If the key is a range, make a copy since map_char_table modifies 566 /* If the key is a range, make a copy since map_char_table modifies
557 it in place. */ 567 it in place. */
558 if (CONSP (key)) 568 if (CONSP (key))
559 key = Fcons (XCAR (key), XCDR (key)); 569 key = Fcons (XCAR (key), XCDR (key));
560 map_keymap_item (fun, XSAVE_OBJECT (args, 2), key, 570 union map_keymap *md = XINTPTR (args);
561 val, XSAVE_POINTER (args, 1)); 571 map_keymap_item (md->s.fun, md->s.args, key, val, md->s.data);
562 } 572 }
563} 573}
564 574
@@ -594,9 +604,11 @@ map_keymap_internal (Lisp_Object map,
594 } 604 }
595 } 605 }
596 else if (CHAR_TABLE_P (binding)) 606 else if (CHAR_TABLE_P (binding))
597 map_char_table (map_keymap_char_table_item, Qnil, binding, 607 {
598 make_save_funcptr_ptr_obj ((voidfuncptr) fun, data, 608 union map_keymap mapdata = {{fun, args, data}};
599 args)); 609 map_char_table (map_keymap_char_table_item, Qnil, binding,
610 make_pointer_integer (&mapdata));
611 }
600 } 612 }
601 613
602 return tail; 614 return tail;