summaryrefslogtreecommitdiffstats
path: root/status.c
diff options
context:
space:
mode:
authornicm <nicm>2017-02-03 21:01:02 +0000
committernicm <nicm>2017-02-03 21:01:02 +0000
commit5e6a8177e55a8e30e0cd67c7ee3039aa22ff1c0e (patch)
tree13019779a1e985f4857616f08d54bffb8fd20008 /status.c
parent75adf8368a649b62bfa4a20e8c21340cf53c2a6a (diff)
Cache status line position to reduce option lookups during output.
Diffstat (limited to 'status.c')
-rw-r--r--status.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/status.c b/status.c
index c4f79050..6cc1ee37 100644
--- a/status.c
+++ b/status.c
@@ -192,17 +192,26 @@ status_timer_start_all(void)
status_timer_start(c);
}
+/* Update status cache. */
+void
+status_update_saved(struct session *s)
+{
+ if (!options_get_number(s->options, "status"))
+ s->statusat = -1;
+ else if (options_get_number(s->options, "status-position") == 0)
+ s->statusat = 0;
+ else
+ s->statusat = 1;
+}
+
/* Get screen line of status line. -1 means off. */
int
status_at_line(struct client *c)
{
struct session *s = c->session;
- if (!options_get_number(s->options, "status"))
- return (-1);
-
- if (options_get_number(s->options, "status-position") == 0)
- return (0);
+ if (s->statusat != 1)
+ return (s->statusat);
return (c->tty.sy - 1);
}