tweaks: avoid calling extra_chunks_in() when not softwrapping

The function is somewhat costly; better avoid it whenever possible.
This commit is contained in:
Benno Schulenberg 2021-04-22 12:17:34 +02:00
parent f54bc6c7d6
commit cf0820549b
2 changed files with 3 additions and 2 deletions

View File

@ -34,7 +34,7 @@ void do_deletion(undo_type action)
int charlen = char_length(openfile->current->data + openfile->current_x);
size_t line_len = strlen(openfile->current->data + openfile->current_x);
#ifndef NANO_TINY
size_t old_amount = extra_chunks_in(openfile->current);
size_t old_amount = ISSET(SOFTWRAP) ? extra_chunks_in(openfile->current) : 0;
/* If the type of action changed or the cursor moved to a different
* line, create a new undo item, otherwise update the existing item. */

View File

@ -1399,12 +1399,13 @@ void inject(char *burst, size_t count)
linestruct *thisline = openfile->current;
size_t datalen = strlen(thisline->data);
#ifndef NANO_TINY
size_t old_amount = extra_chunks_in(openfile->current);
size_t original_row = 0;
size_t old_amount = 0;
if (ISSET(SOFTWRAP)) {
if (openfile->current_y == editwinrows - 1)
original_row = chunk_for(xplustabs(), thisline);
old_amount = extra_chunks_in(thisline);
}
#endif