mirror of
https://github.com/tmux/tmux.git
synced 2025-01-07 16:28:48 +00:00
There are many format variables now so allocating all the default ones
each time a tree is created is too expensive. Instead, convert them all into callbacks and put them in a static table so they only allocate on demand. The tree remains for the moment for extra (non-default) variables added by for example copy mode or popups. Also reduce expensive calls to localtime_r/strftime. GitHub issue 2253.
This commit is contained in:
parent
8986c8dfcd
commit
e858270006
3
tmux.h
3
tmux.h
@ -1944,7 +1944,7 @@ char *paste_make_sample(struct paste_buffer *);
|
|||||||
#define FORMAT_WINDOW 0x40000000U
|
#define FORMAT_WINDOW 0x40000000U
|
||||||
struct format_tree;
|
struct format_tree;
|
||||||
struct format_modifier;
|
struct format_modifier;
|
||||||
typedef char *(*format_cb)(struct format_tree *);
|
typedef void *(*format_cb)(struct format_tree *);
|
||||||
const char *format_skip(const char *, const char *);
|
const char *format_skip(const char *, const char *);
|
||||||
int format_true(const char *);
|
int format_true(const char *);
|
||||||
struct format_tree *format_create(struct client *, struct cmdq_item *, int,
|
struct format_tree *format_create(struct client *, struct cmdq_item *, int,
|
||||||
@ -2713,7 +2713,6 @@ void screen_alternate_off(struct screen *, struct grid_cell *, int);
|
|||||||
/* window.c */
|
/* window.c */
|
||||||
extern struct windows windows;
|
extern struct windows windows;
|
||||||
extern struct window_pane_tree all_window_panes;
|
extern struct window_pane_tree all_window_panes;
|
||||||
extern const struct window_mode *all_window_modes[];
|
|
||||||
int window_cmp(struct window *, struct window *);
|
int window_cmp(struct window *, struct window *);
|
||||||
RB_PROTOTYPE(windows, window, entry, window_cmp);
|
RB_PROTOTYPE(windows, window, entry, window_cmp);
|
||||||
int winlink_cmp(struct winlink *, struct winlink *);
|
int winlink_cmp(struct winlink *, struct winlink *);
|
||||||
|
@ -710,7 +710,7 @@ window_copy_get_line(struct window_pane *wp, u_int y)
|
|||||||
return (format_grid_line(gd, gd->hsize + y));
|
return (format_grid_line(gd, gd->hsize + y));
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static void *
|
||||||
window_copy_cursor_word_cb(struct format_tree *ft)
|
window_copy_cursor_word_cb(struct format_tree *ft)
|
||||||
{
|
{
|
||||||
struct window_pane *wp = format_get_pane(ft);
|
struct window_pane *wp = format_get_pane(ft);
|
||||||
@ -720,7 +720,7 @@ window_copy_cursor_word_cb(struct format_tree *ft)
|
|||||||
return (window_copy_get_word(wp, data->cx, data->cy));
|
return (window_copy_get_word(wp, data->cx, data->cy));
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static void *
|
||||||
window_copy_cursor_line_cb(struct format_tree *ft)
|
window_copy_cursor_line_cb(struct format_tree *ft)
|
||||||
{
|
{
|
||||||
struct window_pane *wp = format_get_pane(ft);
|
struct window_pane *wp = format_get_pane(ft);
|
||||||
@ -730,7 +730,7 @@ window_copy_cursor_line_cb(struct format_tree *ft)
|
|||||||
return (window_copy_get_line(wp, data->cy));
|
return (window_copy_get_line(wp, data->cy));
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static void *
|
||||||
window_copy_search_match_cb(struct format_tree *ft)
|
window_copy_search_match_cb(struct format_tree *ft)
|
||||||
{
|
{
|
||||||
struct window_pane *wp = format_get_pane(ft);
|
struct window_pane *wp = format_get_pane(ft);
|
||||||
|
11
window.c
11
window.c
@ -63,17 +63,6 @@ static u_int next_window_pane_id;
|
|||||||
static u_int next_window_id;
|
static u_int next_window_id;
|
||||||
static u_int next_active_point;
|
static u_int next_active_point;
|
||||||
|
|
||||||
/* List of window modes. */
|
|
||||||
const struct window_mode *all_window_modes[] = {
|
|
||||||
&window_buffer_mode,
|
|
||||||
&window_client_mode,
|
|
||||||
&window_clock_mode,
|
|
||||||
&window_copy_mode,
|
|
||||||
&window_tree_mode,
|
|
||||||
&window_view_mode,
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
struct window_pane_input_data {
|
struct window_pane_input_data {
|
||||||
struct cmdq_item *item;
|
struct cmdq_item *item;
|
||||||
u_int wp;
|
u_int wp;
|
||||||
|
Loading…
Reference in New Issue
Block a user