From b9f994b2c0789ca63e6ad4671e6223554fe36c1d Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Fri, 31 May 2019 17:34:22 +0200 Subject: [PATCH] tweaks: elide a variable, drop a comment, and remove unneeded braces There is no need to save, clear, and restore the mark when counting words, lines and characters, because partitioning and unpartitioning the buffer does not use the mark nor affect it. --- src/text.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/text.c b/src/text.c index 27248bcd..7f207b02 100644 --- a/src/text.c +++ b/src/text.c @@ -3031,17 +3031,15 @@ void do_wordlinechar_count(void) ssize_t lines = 0; size_t current_x_save = openfile->current_x; linestruct *current_save = openfile->current; - linestruct *was_mark = openfile->mark; linestruct *top, *bot; size_t top_x, bot_x; /* If the mark is on, partition the buffer so that it * contains only the marked text, and turn the mark off. */ - if (was_mark) { + if (openfile->mark) { get_region((const linestruct **)&top, &top_x, (const linestruct **)&bot, &bot_x, NULL); filepart = partition_buffer(top, top_x, bot, bot_x); - openfile->mark = NULL; } /* Start at the top of the file. */ @@ -3063,23 +3061,18 @@ void do_wordlinechar_count(void) ((openfile->filebot->data[0] == '\0') ? 0 : 1); /* Get the number of multibyte characters, similar to "wc -c". */ - if (was_mark) { + if (openfile->mark) { chars = get_totsize(openfile->filetop, openfile->filebot); - - /* Unpartition the buffer so that it contains all the text - * again, and turn the mark back on. */ unpartition_buffer(&filepart); - openfile->mark = was_mark; - } else { + } else chars = openfile->totsize; - } /* Restore where we were. */ openfile->current = current_save; openfile->current_x = current_x_save; /* Display the total word, line, and character counts on the statusbar. */ - statusline(HUSH, _("%sWords: %zu Lines: %zd Chars: %zu"), was_mark ? + statusline(HUSH, _("%sWords: %zu Lines: %zd Chars: %zu"), openfile->mark ? _("In Selection: ") : "", words, lines, chars); } #endif /* !NANO_TINY */