Navigation Menu

Skip to content

Commit

Permalink
updated for version 7.3.703
Browse files Browse the repository at this point in the history
Problem:    When 'undofile' is reset the hash is computed unnecessarily.
Solution:   Only compute the hash when the option was set. (Christian Brabandt)
  • Loading branch information
brammool committed Oct 21, 2012
1 parent 354e9e9 commit 9a8ace4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
34 changes: 20 additions & 14 deletions src/option.c
Expand Up @@ -7573,24 +7573,30 @@ set_bool_option(opt_idx, varp, value, opt_flags)
/* 'undofile' */
else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
{
char_u hash[UNDO_HASH_SIZE];
buf_T *save_curbuf = curbuf;

for (curbuf = firstbuf; curbuf != NULL; curbuf = curbuf->b_next)
/* Only take action when the option was set. When reset we do not
* delete the undo file, the option may be set again without making
* any changes in between. */
if (curbuf->b_p_udf || p_udf)
{
/* When 'undofile' is set globally: for every buffer, otherwise
* only for the current buffer: Try to read in the undofile, if
* one exists and the buffer wasn't changed and the buffer was
* loaded. */
if ((curbuf == save_curbuf
|| (opt_flags & OPT_GLOBAL) || opt_flags == 0)
&& !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
char_u hash[UNDO_HASH_SIZE];
buf_T *save_curbuf = curbuf;

for (curbuf = firstbuf; curbuf != NULL; curbuf = curbuf->b_next)
{
u_compute_hash(hash);
u_read_undo(NULL, hash, curbuf->b_fname);
/* When 'undofile' is set globally: for every buffer, otherwise
* only for the current buffer: Try to read in the undofile,
* if one exists, the buffer wasn't changed and the buffer was
* loaded */
if ((curbuf == save_curbuf
|| (opt_flags & OPT_GLOBAL) || opt_flags == 0)
&& !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
{
u_compute_hash(hash);
u_read_undo(NULL, hash, curbuf->b_fname);
}
}
curbuf = save_curbuf;
}
curbuf = save_curbuf;
}
#endif

Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -719,6 +719,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
703,
/**/
702,
/**/
Expand Down

0 comments on commit 9a8ace4

Please sign in to comment.