Karsten Hopp 6fe298
To: vim_dev@googlegroups.com
Karsten Hopp 6fe298
Subject: Patch 7.3.703
Karsten Hopp 6fe298
Fcc: outbox
Karsten Hopp 6fe298
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 6fe298
Mime-Version: 1.0
Karsten Hopp 6fe298
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 6fe298
Content-Transfer-Encoding: 8bit
Karsten Hopp 6fe298
------------
Karsten Hopp 6fe298
Karsten Hopp 6fe298
Patch 7.3.703
Karsten Hopp 6fe298
Problem:    When 'undofile' is reset the hash is computed unnecessarily.
Karsten Hopp 6fe298
Solution:   Only compute the hash when the option was set. (Christian Brabandt)
Karsten Hopp 6fe298
Files:      src/option.c
Karsten Hopp 6fe298
Karsten Hopp 6fe298
Karsten Hopp 6fe298
*** ../vim-7.3.702/src/option.c	2012-10-21 00:10:29.000000000 +0200
Karsten Hopp 6fe298
--- src/option.c	2012-10-21 03:42:10.000000000 +0200
Karsten Hopp 6fe298
***************
Karsten Hopp 6fe298
*** 7573,7596 ****
Karsten Hopp 6fe298
      /* 'undofile' */
Karsten Hopp 6fe298
      else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
Karsten Hopp 6fe298
      {
Karsten Hopp 6fe298
! 	char_u	hash[UNDO_HASH_SIZE];
Karsten Hopp 6fe298
! 	buf_T	*save_curbuf = curbuf;
Karsten Hopp 6fe298
! 
Karsten Hopp 6fe298
! 	for (curbuf = firstbuf; curbuf != NULL; curbuf = curbuf->b_next)
Karsten Hopp 6fe298
  	{
Karsten Hopp 6fe298
! 	    /* When 'undofile' is set globally: for every buffer, otherwise
Karsten Hopp 6fe298
! 	     * only for the current buffer: Try to read in the undofile, if
Karsten Hopp 6fe298
! 	     * one exists and the buffer wasn't changed and the buffer was
Karsten Hopp 6fe298
! 	     * loaded. */
Karsten Hopp 6fe298
! 	    if ((curbuf == save_curbuf
Karsten Hopp 6fe298
! 				|| (opt_flags & OPT_GLOBAL) || opt_flags == 0)
Karsten Hopp 6fe298
! 		    && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
Karsten Hopp 6fe298
  	    {
Karsten Hopp 6fe298
! 		u_compute_hash(hash);
Karsten Hopp 6fe298
! 		u_read_undo(NULL, hash, curbuf->b_fname);
Karsten Hopp 6fe298
  	    }
Karsten Hopp 6fe298
  	}
Karsten Hopp 6fe298
- 	curbuf = save_curbuf;
Karsten Hopp 6fe298
      }
Karsten Hopp 6fe298
  #endif
Karsten Hopp 6fe298
  
Karsten Hopp 6fe298
--- 7573,7602 ----
Karsten Hopp 6fe298
      /* 'undofile' */
Karsten Hopp 6fe298
      else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
Karsten Hopp 6fe298
      {
Karsten Hopp 6fe298
! 	/* Only take action when the option was set. When reset we do not
Karsten Hopp 6fe298
! 	 * delete the undo file, the option may be set again without making
Karsten Hopp 6fe298
! 	 * any changes in between. */
Karsten Hopp 6fe298
! 	if (curbuf->b_p_udf || p_udf)
Karsten Hopp 6fe298
  	{
Karsten Hopp 6fe298
! 	    char_u	hash[UNDO_HASH_SIZE];
Karsten Hopp 6fe298
! 	    buf_T	*save_curbuf = curbuf;
Karsten Hopp 6fe298
! 
Karsten Hopp 6fe298
! 	    for (curbuf = firstbuf; curbuf != NULL; curbuf = curbuf->b_next)
Karsten Hopp 6fe298
  	    {
Karsten Hopp 6fe298
! 		/* When 'undofile' is set globally: for every buffer, otherwise
Karsten Hopp 6fe298
! 		 * only for the current buffer: Try to read in the undofile,
Karsten Hopp 6fe298
! 		 * if one exists, the buffer wasn't changed and the buffer was
Karsten Hopp 6fe298
! 		 * loaded */
Karsten Hopp 6fe298
! 		if ((curbuf == save_curbuf
Karsten Hopp 6fe298
! 				|| (opt_flags & OPT_GLOBAL) || opt_flags == 0)
Karsten Hopp 6fe298
! 			&& !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
Karsten Hopp 6fe298
! 		{
Karsten Hopp 6fe298
! 		    u_compute_hash(hash);
Karsten Hopp 6fe298
! 		    u_read_undo(NULL, hash, curbuf->b_fname);
Karsten Hopp 6fe298
! 		}
Karsten Hopp 6fe298
  	    }
Karsten Hopp 6fe298
+ 	    curbuf = save_curbuf;
Karsten Hopp 6fe298
  	}
Karsten Hopp 6fe298
      }
Karsten Hopp 6fe298
  #endif
Karsten Hopp 6fe298
  
Karsten Hopp 6fe298
*** ../vim-7.3.702/src/version.c	2012-10-21 02:41:04.000000000 +0200
Karsten Hopp 6fe298
--- src/version.c	2012-10-21 03:43:29.000000000 +0200
Karsten Hopp 6fe298
***************
Karsten Hopp 6fe298
*** 721,722 ****
Karsten Hopp 6fe298
--- 721,724 ----
Karsten Hopp 6fe298
  {   /* Add new patch number below this line */
Karsten Hopp 6fe298
+ /**/
Karsten Hopp 6fe298
+     703,
Karsten Hopp 6fe298
  /**/
Karsten Hopp 6fe298
Karsten Hopp 6fe298
-- 
Karsten Hopp 6fe298
Scientists decoded the first message from an alien civilization:
Karsten Hopp 6fe298
        SIMPLY SEND 6 TIMES 10 TO THE 50 ATOMS OF HYDROGEN TO THE STAR
Karsten Hopp 6fe298
SYSTEM AT THE TOP OF THE LIST, CROSS OFF THAT STAR SYSTEM, THEN PUT
Karsten Hopp 6fe298
YOUR STAR SYSTEM AT THE BOTTOM OF THE LIST AND SEND IT TO 100 OTHER
Karsten Hopp 6fe298
STAR SYSTEMS.  WITHIN ONE TENTH GALACTIC ROTATION YOU WILL RECEIVE
Karsten Hopp 6fe298
ENOUGH HYDROGREN TO POWER YOUR CIVILIZATION UNTIL ENTROPY REACHES ITS
Karsten Hopp 6fe298
MAXIMUM!  IT REALLY WORKS!
Karsten Hopp 6fe298
Karsten Hopp 6fe298
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 6fe298
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 6fe298
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 6fe298
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///