From: Paul Eggert Date: Sat, 9 Apr 2011 20:39:49 +0000 (-0700) Subject: * xmenu.c (set_frame_menubar): Allocate smaller local vectors. X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~356^2~13 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e30196164233d058f66efb342eee223f014bf69b;p=emacs.git * xmenu.c (set_frame_menubar): Allocate smaller local vectors. This also lets GCC 4.6.0 generate slightly better loop code. --- diff --git a/src/ChangeLog b/src/ChangeLog index 86dec69e094..084f41fc974 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,8 @@ 2011-04-09 Paul Eggert + * xmenu.c (set_frame_menubar): Allocate smaller local vectors. + This also lets GCC 4.6.0 generate slightly better loop code. + * callint.c (Fcall_interactively): <, not <=, for optimization. (Fcall_interactively): Count the number of arguments produced, not the number of arguments given. This is simpler and lets GCC diff --git a/src/xmenu.c b/src/xmenu.c index dbf8145f737..b1f7dfb26bc 100644 --- a/src/xmenu.c +++ b/src/xmenu.c @@ -966,6 +966,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) Lisp_Object *previous_items = (Lisp_Object *) alloca (previous_menu_items_used * sizeof (Lisp_Object)); + EMACS_UINT subitems; /* If we are making a new widget, its contents are empty, do always reinitialize them. */ @@ -1010,21 +1011,21 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) menu_items = f->menu_bar_vector; menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0; - submenu_start = (int *) alloca (XVECTOR (items)->size * sizeof (int *)); - submenu_end = (int *) alloca (XVECTOR (items)->size * sizeof (int *)); - submenu_n_panes = (int *) alloca (XVECTOR (items)->size * sizeof (int)); - submenu_top_level_items - = (int *) alloca (XVECTOR (items)->size * sizeof (int *)); + subitems = XVECTOR (items)->size / 4; + submenu_start = (int *) alloca (subitems * sizeof (int *)); + submenu_end = (int *) alloca (subitems * sizeof (int *)); + submenu_n_panes = (int *) alloca (subitems * sizeof (int)); + submenu_top_level_items = (int *) alloca (subitems * sizeof (int *)); init_menu_items (); - for (i = 0; i < XVECTOR (items)->size; i += 4) + for (i = 0; i < subitems; i++) { Lisp_Object key, string, maps; last_i = i; - key = XVECTOR (items)->contents[i]; - string = XVECTOR (items)->contents[i + 1]; - maps = XVECTOR (items)->contents[i + 2]; + key = XVECTOR (items)->contents[4 * i]; + string = XVECTOR (items)->contents[4 * i + 1]; + maps = XVECTOR (items)->contents[4 * i + 2]; if (NILP (string)) break; @@ -1051,7 +1052,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) wv->help = Qnil; first_wv = wv; - for (i = 0; i < last_i; i += 4) + for (i = 0; i < last_i; i++) { menu_items_n_panes = submenu_n_panes[i]; wv = digest_single_submenu (submenu_start[i], submenu_end[i],