Skip to content

Commit 9a8ace4

Browse files
committed
updated for version 7.3.703
Problem: When 'undofile' is reset the hash is computed unnecessarily. Solution: Only compute the hash when the option was set. (Christian Brabandt)
1 parent 354e9e9 commit 9a8ace4

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

src/option.c

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7573,24 +7573,30 @@ set_bool_option(opt_idx, varp, value, opt_flags)
75737573
/* 'undofile' */
75747574
else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
75757575
{
7576-
char_u hash[UNDO_HASH_SIZE];
7577-
buf_T *save_curbuf = curbuf;
7578-
7579-
for (curbuf = firstbuf; curbuf != NULL; curbuf = curbuf->b_next)
7576+
/* Only take action when the option was set. When reset we do not
7577+
* delete the undo file, the option may be set again without making
7578+
* any changes in between. */
7579+
if (curbuf->b_p_udf || p_udf)
75807580
{
7581-
/* When 'undofile' is set globally: for every buffer, otherwise
7582-
* only for the current buffer: Try to read in the undofile, if
7583-
* one exists and the buffer wasn't changed and the buffer was
7584-
* loaded. */
7585-
if ((curbuf == save_curbuf
7586-
|| (opt_flags & OPT_GLOBAL) || opt_flags == 0)
7587-
&& !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
7581+
char_u hash[UNDO_HASH_SIZE];
7582+
buf_T *save_curbuf = curbuf;
7583+
7584+
for (curbuf = firstbuf; curbuf != NULL; curbuf = curbuf->b_next)
75887585
{
7589-
u_compute_hash(hash);
7590-
u_read_undo(NULL, hash, curbuf->b_fname);
7586+
/* When 'undofile' is set globally: for every buffer, otherwise
7587+
* only for the current buffer: Try to read in the undofile,
7588+
* if one exists, the buffer wasn't changed and the buffer was
7589+
* loaded */
7590+
if ((curbuf == save_curbuf
7591+
|| (opt_flags & OPT_GLOBAL) || opt_flags == 0)
7592+
&& !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
7593+
{
7594+
u_compute_hash(hash);
7595+
u_read_undo(NULL, hash, curbuf->b_fname);
7596+
}
75917597
}
7598+
curbuf = save_curbuf;
75927599
}
7593-
curbuf = save_curbuf;
75947600
}
75957601
#endif
75967602

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,8 @@ static char *(features[]) =
719719

720720
static int included_patches[] =
721721
{ /* Add new patch number below this line */
722+
/**/
723+
703,
722724
/**/
723725
702,
724726
/**/

0 commit comments

Comments
 (0)