From: Max Kellermann Date: Thu, 11 Jun 2009 15:24:20 +0000 (+0200) Subject: screen: added local "state" variable X-Git-Tag: release-0.15~53 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=cbd8549c2a314928ca98ec8fa15f331dd5e0ef23;p=ncmpc.git screen: added local "state" variable Don't check "status != NULL" each time we need the MPD state. --- 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"))