tweaks: reshuffle some lines, to elide an unneeded assignment

master
Benno Schulenberg 2019-10-02 17:39:45 +02:00
parent 53b77cb4c6
commit c5e46101b1
1 changed files with 6 additions and 8 deletions

View File

@ -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. */ /* Add a new undo item of the given type to the top of the current pile. */
void add_undo(undo_type action) void add_undo(undo_type action)
{ {
undostruct *u = openfile->current_undo; undostruct *u = nmalloc(sizeof(undostruct));
/* The thing we did previously. */
/* Blow away newer undo items if we add somewhere in the middle. */ /* Initialize the newly allocated undo item. */
discard_until(u, openfile, TRUE);
/* Allocate and initialize a new undo item. */
u = (undostruct *) nmalloc(sizeof(undostruct));
u->type = action; u->type = action;
u->strdata = NULL; u->strdata = NULL;
u->cutbuffer = NULL; u->cutbuffer = NULL;
@ -1137,8 +1132,11 @@ void add_undo(undo_type action)
u->mark_begin_x = openfile->current_x; u->mark_begin_x = openfile->current_x;
u->wassize = openfile->totsize; u->wassize = openfile->totsize;
u->newsize = openfile->totsize; u->newsize = openfile->totsize;
u->xflags = 0;
u->grouping = NULL; u->grouping = NULL;
u->xflags = 0;
/* Blow away any undone items. */
discard_until(openfile->current_undo, openfile, TRUE);
#ifdef ENABLE_WRAPPING #ifdef ENABLE_WRAPPING
/* If some action caused automatic long-line wrapping, insert the /* If some action caused automatic long-line wrapping, insert the