From cbd8549c2a314928ca98ec8fa15f331dd5e0ef23 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 11 Jun 2009 17:24:20 +0200 Subject: [PATCH] screen: added local "state" variable Don't check "status != NULL" each time we need the MPD state. --- src/screen.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/screen.c b/src/screen.c index b8102d6..929766b 100644 --- a/src/screen.c +++ b/src/screen.c @@ -296,6 +296,7 @@ paint_status_window(mpdclient_t *c) { WINDOW *w = screen.status_window.w; mpd_Status *status = c->status; + int state; mpd_Song *song = c->song; int elapsedTime = 0; #ifdef NCMPC_MINI @@ -313,7 +314,9 @@ paint_status_window(mpdclient_t *c) wclrtoeol(w); colors_use(w, COLOR_STATUS_BOLD); - switch (status == NULL ? MPD_STATUS_STATE_STOP : status->state) { + state = status == NULL ? MPD_STATUS_STATE_UNKNOWN : status->state; + + switch (state) { case MPD_STATUS_STATE_PLAY: str = _("Playing:"); break; @@ -332,8 +335,7 @@ paint_status_window(mpdclient_t *c) /* create time string */ memset(screen.buf, 0, screen.buf_size); - if (status != NULL && (IS_PLAYING(status->state) || - IS_PAUSED(status->state))) { + if (IS_PLAYING(state) || IS_PAUSED(state)) { if (status->totalTime > 0) { /*checks the conf to see whether to display elapsed or remaining time */ if(!strcmp(options.timedisplay_type,"elapsed")) -- 2.30.2