msg: reduce nesting in mp_msg_flush_status_line

Cosmetic change only.
This commit is contained in:
Kacper Michajłow 2023-12-15 19:40:43 +01:00 committed by Dudemanguy
parent cadb68487e
commit 1306ea9854
1 changed files with 22 additions and 18 deletions

View File

@ -249,25 +249,29 @@ static void prepare_prefix(struct mp_log_root *root, bstr *out, int lev, int ter
void mp_msg_flush_status_line(struct mp_log *log, bool clear) void mp_msg_flush_status_line(struct mp_log *log, bool clear)
{ {
if (log->root) { if (!log->root)
mp_mutex_lock(&log->root->lock); return;
if (log->root->status_lines) {
if (!clear) { mp_mutex_lock(&log->root->lock);
fprintf(stderr, TERM_ESC_RESTORE_CURSOR "\n"); if (!log->root->status_lines)
log->root->blank_lines = 0; goto done;
log->root->status_lines = 0;
goto done; if (!clear) {
} fprintf(stderr, TERM_ESC_RESTORE_CURSOR "\n");
bstr term_msg = (bstr){0}; log->root->blank_lines = 0;
prepare_prefix(log->root, &term_msg, MSGL_STATUS, 0); log->root->status_lines = 0;
if (term_msg.len) { goto done;
fprintf(stderr, "%.*s", BSTR_P(term_msg));
talloc_free(term_msg.start);
}
}
done:
mp_mutex_unlock(&log->root->lock);
} }
bstr term_msg = {0};
prepare_prefix(log->root, &term_msg, MSGL_STATUS, 0);
if (term_msg.len) {
fprintf(stderr, "%.*s", BSTR_P(term_msg));
talloc_free(term_msg.start);
}
done:
mp_mutex_unlock(&log->root->lock);
} }
void mp_msg_set_term_title(struct mp_log *log, const char *title) void mp_msg_set_term_title(struct mp_log *log, const char *title)