mirror of
https://github.com/tmux/tmux.git
synced 2026-06-20 17:25:57 +00:00
Some trivial optimizations.
This commit is contained in:
28
layout.c
28
layout.c
@@ -405,7 +405,8 @@ layout_fix_panes(struct window *w, struct window_pane *skip)
|
||||
struct window_pane *wp;
|
||||
struct layout_cell *lc;
|
||||
int status, scrollbars, sb_pos, sb_w, sb_pad;
|
||||
u_int sx, sy;
|
||||
int old_xoff, old_yoff, changed = 0;
|
||||
u_int sx, sy, old_sx, old_sy;
|
||||
|
||||
status = window_get_pane_status(w);
|
||||
scrollbars = options_get_number(w->options, "pane-scrollbars");
|
||||
@@ -415,6 +416,11 @@ layout_fix_panes(struct window *w, struct window_pane *skip)
|
||||
if ((lc = wp->layout_cell) == NULL || wp == skip)
|
||||
continue;
|
||||
|
||||
old_xoff = wp->xoff;
|
||||
old_yoff = wp->yoff;
|
||||
old_sx = wp->sx;
|
||||
old_sy = wp->sy;
|
||||
|
||||
wp->xoff = lc->xoff;
|
||||
wp->yoff = lc->yoff;
|
||||
sx = lc->sx;
|
||||
@@ -452,8 +458,15 @@ layout_fix_panes(struct window *w, struct window_pane *skip)
|
||||
}
|
||||
|
||||
window_pane_resize(wp, sx, sy);
|
||||
|
||||
if (wp->xoff != old_xoff ||
|
||||
wp->yoff != old_yoff ||
|
||||
wp->sx != old_sx ||
|
||||
wp->sy != old_sy)
|
||||
changed = 1;
|
||||
}
|
||||
screen_redraw_invalidate_scene(w);
|
||||
if (changed)
|
||||
screen_redraw_invalidate_scene(w);
|
||||
}
|
||||
|
||||
/* Count the number of available cells in a layout. */
|
||||
@@ -774,10 +787,15 @@ layout_resize_floating_pane_to(struct window_pane *wp, enum layout_type type,
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == LAYOUT_TOPBOTTOM)
|
||||
if (type == LAYOUT_TOPBOTTOM) {
|
||||
if (lc->sy == size)
|
||||
return;
|
||||
lc->sy = size;
|
||||
else
|
||||
} else {
|
||||
if (lc->sx == size)
|
||||
return;
|
||||
lc->sx = size;
|
||||
}
|
||||
screen_redraw_invalidate_scene(wp->window);
|
||||
}
|
||||
|
||||
@@ -793,6 +811,8 @@ layout_resize_floating_pane(struct window_pane *wp, enum layout_type type,
|
||||
*cause = xstrdup("pane is not floating");
|
||||
return;
|
||||
}
|
||||
if (change == 0)
|
||||
return;
|
||||
|
||||
if (type == LAYOUT_TOPBOTTOM) {
|
||||
size = lc->sy + change;
|
||||
|
||||
@@ -164,6 +164,9 @@ struct redraw_build_cell {
|
||||
struct redraw_span_data data;
|
||||
};
|
||||
|
||||
static struct redraw_build_cell *screen_redraw_cells;
|
||||
static size_t screen_redraw_ncells;
|
||||
|
||||
/* Context for building the scene. */
|
||||
struct redraw_build_ctx {
|
||||
struct client *c;
|
||||
@@ -864,22 +867,24 @@ screen_redraw_make_scene(struct client *c)
|
||||
if (bctx.sx != 0 && bctx.sy > SIZE_MAX / bctx.sx)
|
||||
fatalx("%s: too many cells", __func__);
|
||||
ncells = (size_t)bctx.sx * bctx.sy;
|
||||
if (ncells > SIZE_MAX / sizeof *bctx.cells)
|
||||
fatalx("%s: too many cells", __func__);
|
||||
bctx.cells = xmalloc(ncells * sizeof *bctx.cells);
|
||||
if (ncells > screen_redraw_ncells) {
|
||||
screen_redraw_cells = xreallocarray(screen_redraw_cells, ncells,
|
||||
sizeof *screen_redraw_cells);
|
||||
screen_redraw_ncells = ncells;
|
||||
}
|
||||
bctx.cells = screen_redraw_cells;
|
||||
for (y = 0; y < bctx.sy; y++) {
|
||||
for (x = 0; x < bctx.sx; x++)
|
||||
screen_redraw_reset_cell(&bctx, x, y);
|
||||
}
|
||||
|
||||
TAILQ_FOREACH_REVERSE(wp, &bctx.w->z_index, window_panes_zindex, zentry)
|
||||
screen_redraw_mark_pane(&bctx, wp);
|
||||
screen_redraw_mark_pane(&bctx, wp);
|
||||
|
||||
screen_redraw_mark_two_pane_colours(&bctx);
|
||||
screen_redraw_finish_scene(&bctx, scene);
|
||||
log_debug("%s: finished @%u scene build", c->name, scene->w->id);
|
||||
|
||||
free(bctx.cells);
|
||||
return (scene);
|
||||
}
|
||||
|
||||
@@ -1463,8 +1468,10 @@ screen_redraw_draw(struct client *c, struct window_pane *wp, int flags)
|
||||
}
|
||||
}
|
||||
|
||||
log_debug("%s: starting @%u redraw (%s)", c->name, w->id,
|
||||
screen_redraw_flags_string(flags));
|
||||
if (log_get_level() != 0) {
|
||||
log_debug("%s: starting @%u redraw (%s)", c->name, w->id,
|
||||
screen_redraw_flags_string(flags));
|
||||
}
|
||||
|
||||
scene = screen_redraw_get_scene(c);
|
||||
if (scene == NULL)
|
||||
|
||||
Reference in New Issue
Block a user