From e064bd60df7e9ff611334e5e639bab18a084fac2 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 31 Aug 2009 03:54:10 +0200 Subject: [PATCH] De-inline 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: 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 Signed-off-by: Denys Vlasenko Signed-off-by: Sergei Trofimovich --- edit/bookmark.c | 2 +- edit/edit.c | 4 ++-- edit/syntax.c | 6 +++--- src/achown.c | 2 +- src/chown.c | 2 +- src/dialog.c | 6 +++--- src/find.c | 2 +- src/hotlist.c | 2 +- src/menu.c | 6 +++--- src/screen.c | 8 ++++---- src/tree.c | 2 +- src/tty/key.c | 2 +- src/viewer/datasource.c | 2 +- vfs/vfs.c | 8 ++++---- 14 files changed, 27 insertions(+), 27 deletions(-) diff --git a/edit/bookmark.c b/edit/bookmark.c index e838d168b..00dfe8ea5 100644 --- a/edit/bookmark.c +++ b/edit/bookmark.c @@ -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 --git a/edit/edit.c b/edit/edit.c index c8e551ab5..118932a34 100644 --- a/edit/edit.c +++ b/edit/edit.c @@ -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 --git a/edit/syntax.c b/edit/syntax.c index df9e3ff44..6ef4bfcb4 100644 --- a/edit/syntax.c +++ b/edit/syntax.c @@ -131,7 +131,7 @@ mc_defines_destroy (gpointer key, gpointer value, gpointer data) } /* 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 i, const char *text, 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 (const unsigned char *s, int c) 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 --git a/src/achown.c b/src/achown.c index 6b868c78f..cdac09855 100644 --- a/src/achown.c +++ b/src/achown.c @@ -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 --git a/src/chown.c b/src/chown.c index c1d2c8ba8..486f578bd 100644 --- a/src/chown.c +++ b/src/chown.c @@ -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 --git a/src/dialog.c b/src/dialog.c index c9c8245a6..67ab09db5 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -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 key, Gpm_Event *event) dlg_key_event (h, key); } -static inline void +static void frontend_run_dlg (Dlg_head *h) { int d_key; diff --git a/src/find.c b/src/find.c index e9581d1bd..bc061c634 100644 --- a/src/find.c +++ b/src/find.c @@ -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 --git a/src/hotlist.c b/src/hotlist.c index 8cc5dc7b0..27cc88c57 100644 --- a/src/hotlist.c +++ b/src/hotlist.c @@ -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 --git a/src/menu.c b/src/menu.c index 71799d3e6..1edd68d48 100644 --- a/src/menu.c +++ b/src/menu.c @@ -125,7 +125,7 @@ static void menubar_paint_idx (WMenu *menubar, int idx, int color) } } -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 --git a/src/screen.c b/src/screen.c index cfee8a975..ba2fc76bf 100644 --- a/src/screen.c +++ b/src/screen.c @@ -177,7 +177,7 @@ string_file_name (file_entry *fe, int len) 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 --git a/src/tree.c b/src/tree.c index 51ebfa920..a3b1e12b7 100644 --- a/src/tree.c +++ b/src/tree.c @@ -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 --git a/src/tty/key.c b/src/tty/key.c index c2d81f6f4..c7e52815b 100644 --- a/src/tty/key.c +++ b/src/tty/key.c @@ -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 --git a/src/viewer/datasource.c b/src/viewer/datasource.c index 2a3fea4c1..15abc9389 100644 --- a/src/viewer/datasource.c +++ b/src/viewer/datasource.c @@ -233,7 +233,7 @@ mcview_set_byte (mcview_t * view, off_t offset, byte b) /* --------------------------------------------------------------------------------------------- */ -/*static inline*/ +/*static*/ void mcview_file_load_data (mcview_t * view, off_t byte_index) { diff --git a/vfs/vfs.c b/vfs/vfs.c index cbe24afa1..713f24246 100644 --- a/vfs/vfs.c +++ b/vfs/vfs.c @@ -131,7 +131,7 @@ vfs_new_handle (struct vfs_class *vclass, void *fsinfo) } /** 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 char *filename) return p; } -static inline int +static int path_magic (const char *path) { struct stat buf;