* xmenu.c (set_frame_menubar): Allocate smaller local vectors.
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 9 Apr 2011 20:39:49 +0000 (13:39 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 9 Apr 2011 20:39:49 +0000 (13:39 -0700)
This also lets GCC 4.6.0 generate slightly better loop code.

src/ChangeLog
src/xmenu.c

index 86dec69..084f41f 100644 (file)
@@ -1,5 +1,8 @@
 2011-04-09  Paul Eggert  <eggert@cs.ucla.edu>
 
+       * 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
index dbf8145..b1f7dfb 100644 (file)
@@ -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],