Eliding a variable -- there is no need to optimize for calls of strlen(),

as this is typing speed, no need to hurry.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5663 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Benno Schulenberg 2016-02-22 14:26:05 +00:00
parent 7c0e433305
commit 3ed08c568f
2 changed files with 6 additions and 9 deletions

View File

@ -6,6 +6,7 @@
src/move.c (do_prev_word, do_next_word): Sort these in standard way.
* src/prompt.c (do_statusbar_output): Don't move too many bytes.
This fixes Savannah bug #47219 (uncovered by r5655).
* src/prompt.c (do_statusbar_output): Elide a variable.
2016-02-21 Benno Schulenberg <bensberg@justemail.net>
* src/files.c (input_tab): If the first Tab added the part that all

View File

@ -246,10 +246,9 @@ int do_statusbar_mouse(void)
void do_statusbar_output(int *the_input, size_t input_len,
bool filtering, bool *got_enter)
{
size_t answer_len, i;
char *output = charalloc(input_len + 1);
char *char_buf = charalloc(mb_cur_max());
int char_buf_len;
int i, char_buf_len;
assert(answer != NULL);
@ -258,7 +257,6 @@ void do_statusbar_output(int *the_input, size_t input_len,
output[i] = (char)the_input[i];
output[i] = '\0';
answer_len = strlen(answer);
i = 0;
while (i < input_len) {
@ -284,15 +282,13 @@ void do_statusbar_output(int *the_input, size_t input_len,
if (filtering && is_ascii_cntrl_char(*(output + i - char_buf_len)))
continue;
/* More dangerousness fun. =) */
answer = charealloc(answer, answer_len + char_buf_len + 1);
assert(statusbar_x <= answer_len);
assert(statusbar_x <= strlen(answer));
/* Insert the typed character into the existing answer string. */
answer = charealloc(answer, strlen(answer) + char_buf_len + 1);
charmove(answer + statusbar_x + char_buf_len, answer + statusbar_x,
answer_len - statusbar_x + 1);
strlen(answer) - statusbar_x + 1);
strncpy(answer + statusbar_x, char_buf, char_buf_len);
answer_len += char_buf_len;
statusbar_x += char_buf_len;
}