From c5e46101b1876252af608161ba4dadd3c686d289 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 2 Oct 2019 17:39:45 +0200 Subject: [PATCH] tweaks: reshuffle some lines, to elide an unneeded assignment --- src/text.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/text.c b/src/text.c index a97de2b4..bcd12a16 100644 --- a/src/text.c +++ b/src/text.c @@ -1120,14 +1120,9 @@ void discard_until(const undostruct *thisitem, openfilestruct *thefile, bool kee /* Add a new undo item of the given type to the top of the current pile. */ void add_undo(undo_type action) { - undostruct *u = openfile->current_undo; - /* The thing we did previously. */ + undostruct *u = nmalloc(sizeof(undostruct)); - /* Blow away newer undo items if we add somewhere in the middle. */ - discard_until(u, openfile, TRUE); - - /* Allocate and initialize a new undo item. */ - u = (undostruct *) nmalloc(sizeof(undostruct)); + /* Initialize the newly allocated undo item. */ u->type = action; u->strdata = NULL; u->cutbuffer = NULL; @@ -1137,8 +1132,11 @@ void add_undo(undo_type action) u->mark_begin_x = openfile->current_x; u->wassize = openfile->totsize; u->newsize = openfile->totsize; - u->xflags = 0; u->grouping = NULL; + u->xflags = 0; + + /* Blow away any undone items. */ + discard_until(openfile->current_undo, openfile, TRUE); #ifdef ENABLE_WRAPPING /* If some action caused automatic long-line wrapping, insert the