From fb04dff6d78d06ec8e87d177530a496fa47aa3ce Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 4 Apr 2019 14:44:44 +0200 Subject: [PATCH] tweaks: don't bother reallocating the data when a line gets hard-wrapped This will waste some memory, but... if the user keeps editing, she is likely to revisit the line and the data will get reallocated soon enough. --- src/text.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/text.c b/src/text.c index 436bc928..0eeafd8f 100644 --- a/src/text.c +++ b/src/text.c @@ -898,7 +898,8 @@ void do_enter(void) } #endif - null_at(&openfile->current->data, openfile->current_x); + /* Make the current line end at the cursor position. */ + openfile->current->data[openfile->current_x] = '\0'; #ifndef NANO_TINY add_undo(ENTER); @@ -1910,7 +1911,7 @@ void rewrap_paragraph(linestruct **line, char *lead_string, size_t lead_len) } /* Now actually break the current line, and go to the next. */ - null_at(&(*line)->data, break_pos); + (*line)->data[break_pos] = '\0'; *line = (*line)->next; }