commit cf0820549b1573b249f0f0ebb1297a962484ab41
parent f54bc6c7d645ff18825cf323885147162524110f
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Thu, 22 Apr 2021 12:17:34 +0200
tweaks: avoid calling extra_chunks_in() when not softwrapping
The function is somewhat costly; better avoid it whenever possible.
Diffstat:
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/cut.c b/src/cut.c
@@ -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. */
diff --git a/src/nano.c b/src/nano.c
@@ -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