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