commit fb04dff6d78d06ec8e87d177530a496fa47aa3ce
parent c224ea3ce770ab5f0aba889b673d246d5efe39cd
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Thu, 4 Apr 2019 14:44:44 +0200
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.
Diffstat:
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git 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;
}