[PATCH] trivial: de-inline large functions



Hi Slava, folks,

The attached patch de-inlines a few functions
which are large, or not-so-large but nevertheless
contain more than one function call,
or contain loops, or contain if's and at least one
function call, or contain largish objects on stack.

In my experience, in those cases the code size
growth is big enough to not inline stuff.

I guess some of the really big functions
are defined inline because they have, or had in the past,
just one callsite.

But for a few years gcc already does it automatically,
no need to do it by hand and risk code size explosion
when later during code evolution another callsite
is created. This optimization by hand is simply
no longer needed.

Anyway, here is the code size difference:

# size */.obj/src/mc
   text    data     bss     dec     hex filename
 572337   17944  177820  768101   bb865 mc.t5/.obj/src/mc
 567697   17944  177820  763461   ba645 mc.t6/.obj/src/mc

Please apply.
-- 
vda
diff -d -urpN mc.5/edit/bookmark.c mc.6/edit/bookmark.c
--- mc.5/edit/bookmark.c	2009-07-10 23:39:18.000000000 +0200
+++ mc.6/edit/bookmark.c	2009-08-30 16:08:28.000000000 +0200
@@ -49,7 +49,7 @@
    appended after each other and the last one is always the one found
    by book_mark_found() i.e. last in is the one seen */
 
-static inline struct _book_mark *double_marks (WEdit * edit, struct _book_mark *p)
+static struct _book_mark *double_marks (WEdit * edit, struct _book_mark *p)
 {
     (void) edit;
 
diff -d -urpN mc.5/edit/edit.c mc.6/edit/edit.c
--- mc.5/edit/edit.c	2009-08-30 05:23:10.000000000 +0200
+++ mc.6/edit/edit.c	2009-08-30 16:08:37.000000000 +0200
@@ -634,7 +634,7 @@ edit_save_position (WEdit *edit)
 }
 
 /* Clean the WEdit stricture except the widget part */
-static inline void
+static void
 edit_purge_widget (WEdit *edit)
 {
     int len = sizeof (WEdit) - sizeof (Widget);
@@ -1030,7 +1030,7 @@ pop_action (WEdit * edit)
 }
 
 /* is called whenever a modification is made by one of the four routines below */
-static inline void edit_modification (WEdit * edit)
+static void edit_modification (WEdit * edit)
 {
     edit->caches_valid = 0;
     edit->screen_modified = 1;
diff -d -urpN mc.5/edit/syntax.c mc.6/edit/syntax.c
--- mc.5/edit/syntax.c	2009-08-30 05:23:10.000000000 +0200
+++ mc.6/edit/syntax.c	2009-08-30 16:08:23.000000000 +0200
@@ -131,7 +131,7 @@ mc_defines_destroy (gpointer key, gpoint
 }
 
 /* Completely destroys the defines tree */
-static inline void
+static void
 destroy_defines (GTree **defines)
 {
     g_tree_traverse (*defines, mc_defines_destroy, G_POST_ORDER, NULL);
@@ -292,7 +292,7 @@ compare_word_to_right (WEdit *edit, long
     return i;
 }
 
-static inline const char *xx_strchr (const unsigned char *s, int c)
+static const char *xx_strchr (const unsigned char *s, int c)
 {
     while (*s >= '\005' && *s != (unsigned char) c) {
 	s++;
@@ -300,7 +300,7 @@ static inline const char *xx_strchr (con
     return (const char *) s;
 }
 
-static inline struct syntax_rule apply_rules_going_right (WEdit * edit, long i, struct syntax_rule rule)
+static struct syntax_rule apply_rules_going_right (WEdit * edit, long i, struct syntax_rule rule)
 {
     struct context_rule *r;
     int contextchanged = 0, c;
diff -d -urpN mc.5/src/achown.c mc.6/src/achown.c
--- mc.5/src/achown.c	2009-08-30 05:23:10.000000000 +0200
+++ mc.6/src/achown.c	2009-08-30 16:11:49.000000000 +0200
@@ -612,7 +612,7 @@ chown_advanced_done (void)
 }
 
 #if 0
-static inline void do_chown (uid_t u, gid_t g)
+static void do_chown (uid_t u, gid_t g)
 {
     chown (current_panel->dir.list[current_file].fname, u, g);
     file_mark (current_panel, current_file, 0);
diff -d -urpN mc.5/src/chown.c mc.6/src/chown.c
--- mc.5/src/chown.c	2009-08-30 05:23:10.000000000 +0200
+++ mc.6/src/chown.c	2009-08-30 16:09:24.000000000 +0200
@@ -215,7 +215,7 @@ chown_done (void)
     repaint_screen ();
 }
 
-static inline void
+static void
 do_chown (uid_t u, gid_t g)
 {
     if (mc_chown (current_panel->dir.list [current_file].fname, u, g) == -1)
diff -d -urpN mc.5/src/dialog.c mc.6/src/dialog.c
--- mc.5/src/dialog.c	2009-08-30 05:23:10.000000000 +0200
+++ mc.6/src/dialog.c	2009-08-30 16:10:57.000000000 +0200
@@ -587,7 +587,7 @@ void dlg_stop (Dlg_head *h)
     h->running = 0;
 }
 
-static inline void
+static void
 dialog_handle_key (Dlg_head *h, int d_key)
 {
     if (is_abort_char (d_key)) {
@@ -732,7 +732,7 @@ dlg_key_event (Dlg_head *h, int d_key)
     (*h->callback) (h, DLG_POST_KEY, d_key);
 }
 
-static inline int
+static int
 dlg_mouse_event (Dlg_head * h, Gpm_Event * event)
 {
     Widget *item;
@@ -826,7 +826,7 @@ void dlg_process_event (Dlg_head *h, int
 	dlg_key_event (h, key);
 }
 
-static inline void
+static void
 frontend_run_dlg (Dlg_head *h)
 {
     int d_key;
diff -d -urpN mc.5/src/find.c mc.6/src/find.c
--- mc.5/src/find.c	2009-08-30 05:23:10.000000000 +0200
+++ mc.6/src/find.c	2009-08-30 16:10:27.000000000 +0200
@@ -186,7 +186,7 @@ status_update (const char *text)
     label_set_text (status_label, text);
 }
 
-static inline void
+static void
 found_num_update (void)
 {
     char buffer [BUF_TINY];
diff -d -urpN mc.5/src/hotlist.c mc.6/src/hotlist.c
--- mc.5/src/hotlist.c	2009-08-30 05:23:10.000000000 +0200
+++ mc.6/src/hotlist.c	2009-08-30 16:10:43.000000000 +0200
@@ -175,7 +175,7 @@ hotlist_refresh (Dlg_head * dlg)
 }
 
 /* If current->data is 0, then we are dealing with a VFS pathname */
-static inline void
+static void
 update_path_name (void)
 {
     const char *text = "";
diff -d -urpN mc.5/src/menu.c mc.6/src/menu.c
--- mc.5/src/menu.c	2009-08-30 05:23:10.000000000 +0200
+++ mc.6/src/menu.c	2009-08-30 16:10:14.000000000 +0200
@@ -125,7 +125,7 @@ static void menubar_paint_idx (WMenu *me
     }
 }
 
-static inline void menubar_draw_drop (WMenu *menubar)
+static void menubar_draw_drop (WMenu *menubar)
 {
     const int count = menubar->menu [menubar->selected]->count;
     int column = menubar->menu [menubar->selected]->start_x - 1;
@@ -190,10 +190,10 @@ static void menubar_draw (WMenu *menubar
 		menubar-> menu[menubar->selected]->start_x);
 }
 
-static inline void menubar_remove (WMenu *menubar)
+static void menubar_remove (WMenu *menubar)
 {
     menubar->subsel = 0;
-    if (menubar->dropped){
+    if (menubar->dropped) {
 	menubar->dropped = 0;
 	do_refresh ();
 	menubar->dropped = 1;
diff -d -urpN mc.5/src/screen.c mc.6/src/screen.c
--- mc.5/src/screen.c	2009-08-30 05:23:10.000000000 +0200
+++ mc.6/src/screen.c	2009-08-30 16:11:44.000000000 +0200
@@ -177,7 +177,7 @@ string_file_name (file_entry *fe, int le
     return buffer;
 }
 
-static inline unsigned int ilog10(dev_t n)
+static unsigned int ilog10(dev_t n)
 {
     unsigned int digits = 0;
     do {
@@ -968,7 +968,7 @@ do_select (WPanel *panel, int i)
     }
 }
 
-static inline void
+static void
 do_try_to_select (WPanel *panel, const char *name)
 {
     int i;
@@ -2374,7 +2374,7 @@ static const panel_key_map panel_keymap 
     { 0, 0 }
 };
 
-static inline cb_ret_t
+static cb_ret_t
 panel_key (WPanel *panel, int key)
 {
     int i;
@@ -2521,7 +2521,7 @@ mouse_set_mark (WPanel *panel)
 	do_mark_file (panel, 0);
 }
 
-static inline int
+static int
 mark_if_marking (WPanel *panel, Gpm_Event *event)
 {
     if (event->buttons & GPM_B_RIGHT){
diff -d -urpN mc.5/src/tree.c mc.6/src/tree.c
--- mc.5/src/tree.c	2009-08-30 05:23:10.000000000 +0200
+++ mc.6/src/tree.c	2009-08-30 16:09:52.000000000 +0200
@@ -907,7 +907,7 @@ static const tree_key_map tree_keymap []
     { 0, 0 }
     };
 
-static inline cb_ret_t
+static cb_ret_t
 tree_key (WTree *tree, int key)
 {
     int i;
diff -d -urpN mc.5/src/tty/key.c mc.6/src/tty/key.c
--- mc.5/src/tty/key.c	2009-08-30 05:23:11.000000000 +0200
+++ mc.6/src/tty/key.c	2009-08-30 16:08:03.000000000 +0200
@@ -485,7 +485,7 @@ static Window x11_window;
 
 /*** file scope functions **********************************************/
 
-inline static int
+static int
 add_selects (fd_set *select_set)
 {
     int top_fd = 0;
diff -d -urpN mc.5/src/viewer/datasource.c mc.6/src/viewer/datasource.c
--- mc.5/src/viewer/datasource.c	2009-08-30 05:23:11.000000000 +0200
+++ mc.6/src/viewer/datasource.c	2009-08-30 16:07:55.000000000 +0200
@@ -233,7 +233,7 @@ mcview_set_byte (mcview_t * view, off_t 
 
 /* --------------------------------------------------------------------------------------------- */
 
-/*static inline*/
+/*static*/
 void
 mcview_file_load_data (mcview_t * view, off_t byte_index)
 {
diff -d -urpN mc.5/vfs/vfs.c mc.6/vfs/vfs.c
--- mc.5/vfs/vfs.c	2009-08-30 05:23:11.000000000 +0200
+++ mc.6/vfs/vfs.c	2009-08-30 16:09:14.000000000 +0200
@@ -131,7 +131,7 @@ vfs_new_handle (struct vfs_class *vclass
 }
 
 /** Find VFS class by file handle */
-static inline struct vfs_class *
+static struct vfs_class *
 vfs_op (int handle)
 {
     struct vfs_openfile *h;
@@ -151,7 +151,7 @@ vfs_op (int handle)
 }
 
 /** Find private file data by file handle */
-static inline void *
+static void *
 vfs_info (int handle)
 {
     struct vfs_openfile *h;
@@ -171,7 +171,7 @@ vfs_info (int handle)
 }
 
 /** Free open file data for given file handle */
-static inline void
+static void
 vfs_free_handle (int handle)
 {
     if (handle < VFS_FIRST_HANDLE ||
@@ -253,7 +253,7 @@ vfs_strip_suffix_from_filename (const ch
     return p;
 }
 
-static inline int
+static int
 path_magic (const char *path)
 {
     struct stat buf;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]