From cf0820549b1573b249f0f0ebb1297a962484ab41 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 22 Apr 2021 12:17:34 +0200 Subject: [PATCH] tweaks: avoid calling extra_chunks_in() when not softwrapping The function is somewhat costly; better avoid it whenever possible. --- src/cut.c | 2 +- src/nano.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cut.c b/src/cut.c index 9079ce97..6793798b 100644 --- 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 index 1011148f..4f151bce 100644 --- 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