summaryrefslogtreecommitdiff
path: root/src/option.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2012-10-21 03:46:05 +0200
committerBram Moolenaar <Bram@vim.org>2012-10-21 03:46:05 +0200
commite8d8fd2add98a95e6c776deb54e2a2c59fddf1c7 (patch)
treeb74b9405da89481752b04bf53a0c52668dcd4e95 /src/option.c
parent3a0d8090b1356833e1c80d22f36086c835604f42 (diff)
downloadvim-git-e8d8fd2add98a95e6c776deb54e2a2c59fddf1c7.tar.gz
updated for version 7.3.703v7.3.703
Problem: When 'undofile' is reset the hash is computed unnecessarily. Solution: Only compute the hash when the option was set. (Christian Brabandt)
Diffstat (limited to 'src/option.c')
-rw-r--r--src/option.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/option.c b/src/option.c
index da9807156..2ab077063 100644
--- a/src/option.c
+++ b/src/option.c
@@ -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