summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/grid-view.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2015-11-13 08:09:28 +0000
committernicm <nicm@openbsd.org>2015-11-13 08:09:28 +0000
commite931849fc48dd16f7d4297c9110bef9c92b73430 (patch)
tree30c7b11451424e9628df9258a07ef6e7f2df2da1 /usr.bin/tmux/grid-view.c
parenttweaks; (diff)
downloadwireguard-openbsd-e931849fc48dd16f7d4297c9110bef9c92b73430.tar.xz
wireguard-openbsd-e931849fc48dd16f7d4297c9110bef9c92b73430.zip
Long overdue change to the way we store cells in the grid: now, instead
of storing a full grid_cell with UTF-8 data and everything, store a new type grid_cell_entry. This can either be the cell itself (for ASCII cells), or an offset into an extended array (per line) for UTF-8 data. This avoid a large (8 byte) overhead on non-UTF-8 cells (by far the majority for most users) without the complexity of the shadow array we had before. Grid memory without any UTF-8 is about half. The disadvantage that cells can no longer be modified in place and need to be copied out of the grid and back but it turned out to be lot less complicated than I expected.
Diffstat (limited to 'usr.bin/tmux/grid-view.c')
-rw-r--r--usr.bin/tmux/grid-view.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/usr.bin/tmux/grid-view.c b/usr.bin/tmux/grid-view.c
index c0deb6b07bb..86d1feba6bc 100644
--- a/usr.bin/tmux/grid-view.c
+++ b/usr.bin/tmux/grid-view.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grid-view.c,v 1.21 2015/01/06 21:14:42 nicm Exp $ */
+/* $OpenBSD: grid-view.c,v 1.22 2015/11/13 08:09:28 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -30,24 +30,17 @@
#define grid_view_x(gd, x) (x)
#define grid_view_y(gd, y) ((gd)->hsize + (y))
-/* Get cell for reading. */
-const struct grid_cell *
-grid_view_peek_cell(struct grid *gd, u_int px, u_int py)
-{
- return (grid_peek_cell(gd, grid_view_x(gd, px), grid_view_y(gd, py)));
-}
-
-/* Get cell for writing. */
-struct grid_cell *
-grid_view_get_cell(struct grid *gd, u_int px, u_int py)
+/* Get cel. */
+void
+grid_view_get_cell(struct grid *gd, u_int px, u_int py, struct grid_cell *gc)
{
- return (grid_get_cell(gd, grid_view_x(gd, px), grid_view_y(gd, py)));
+ grid_get_cell(gd, grid_view_x(gd, px), grid_view_y(gd, py), gc);
}
/* Set cell. */
void
-grid_view_set_cell(
- struct grid *gd, u_int px, u_int py, const struct grid_cell *gc)
+grid_view_set_cell(struct grid *gd, u_int px, u_int py,
+ const struct grid_cell *gc)
{
grid_set_cell(gd, grid_view_x(gd, px), grid_view_y(gd, py), gc);
}