comparison src/ex_getln.c @ 9487:69ed2c9d34a6 v7.4.2024

commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 10 22:11:16 2016 +0200 patch 7.4.2024 Problem: More buf_valid() calls can be optimized. Solution: Use bufref_valid() instead.
author Christian Brabandt <cb@256bit.org>
date Sun, 10 Jul 2016 22:15:06 +0200
parents 32e34e574716
children 98b39d2eb895
comparison
equal deleted inserted replaced
9486:b931ed8a6782 9487:69ed2c9d34a6
1664 1664
1665 #ifdef FEAT_RIGHTLEFT 1665 #ifdef FEAT_RIGHTLEFT
1666 case Ctrl__: /* CTRL-_: switch language mode */ 1666 case Ctrl__: /* CTRL-_: switch language mode */
1667 if (!p_ari) 1667 if (!p_ari)
1668 break; 1668 break;
1669 #ifdef FEAT_FKMAP 1669 # ifdef FEAT_FKMAP
1670 if (p_altkeymap) 1670 if (p_altkeymap)
1671 { 1671 {
1672 cmd_fkmap = !cmd_fkmap; 1672 cmd_fkmap = !cmd_fkmap;
1673 if (cmd_fkmap) /* in Farsi always in Insert mode */ 1673 if (cmd_fkmap) /* in Farsi always in Insert mode */
1674 ccline.overstrike = FALSE; 1674 ccline.overstrike = FALSE;
1675 } 1675 }
1676 else /* Hebrew is default */ 1676 else /* Hebrew is default */
1677 #endif 1677 # endif
1678 cmd_hkmap = !cmd_hkmap; 1678 cmd_hkmap = !cmd_hkmap;
1679 goto cmdline_not_changed; 1679 goto cmdline_not_changed;
1680 #endif 1680 #endif
1681 1681
1682 default: 1682 default:
6653 */ 6653 */
6654 static int 6654 static int
6655 ex_window(void) 6655 ex_window(void)
6656 { 6656 {
6657 struct cmdline_info save_ccline; 6657 struct cmdline_info save_ccline;
6658 buf_T *old_curbuf = curbuf; 6658 bufref_T old_curbuf;
6659 win_T *old_curwin = curwin; 6659 win_T *old_curwin = curwin;
6660 buf_T *bp; 6660 bufref_T bufref;
6661 win_T *wp; 6661 win_T *wp;
6662 int i; 6662 int i;
6663 linenr_T lnum; 6663 linenr_T lnum;
6664 int histtype; 6664 int histtype;
6665 garray_T winsizes; 6665 garray_T winsizes;
6684 ) 6684 )
6685 { 6685 {
6686 beep_flush(); 6686 beep_flush();
6687 return K_IGNORE; 6687 return K_IGNORE;
6688 } 6688 }
6689 set_bufref(&old_curbuf, curbuf);
6689 6690
6690 /* Save current window sizes. */ 6691 /* Save current window sizes. */
6691 win_size_save(&winsizes); 6692 win_size_save(&winsizes);
6692 6693
6693 # ifdef FEAT_AUTOCMD 6694 # ifdef FEAT_AUTOCMD
6830 6831
6831 exmode_active = save_exmode; 6832 exmode_active = save_exmode;
6832 6833
6833 /* Safety check: The old window or buffer was deleted: It's a bug when 6834 /* Safety check: The old window or buffer was deleted: It's a bug when
6834 * this happens! */ 6835 * this happens! */
6835 if (!win_valid(old_curwin) || !buf_valid(old_curbuf)) 6836 if (!win_valid(old_curwin) || !bufref_valid(&old_curbuf))
6836 { 6837 {
6837 cmdwin_result = Ctrl_C; 6838 cmdwin_result = Ctrl_C;
6838 EMSG(_("E199: Active window or buffer deleted")); 6839 EMSG(_("E199: Active window or buffer deleted"));
6839 } 6840 }
6840 else 6841 else
6901 # ifdef FEAT_CONCEAL 6902 # ifdef FEAT_CONCEAL
6902 /* Avoid command-line window first character being concealed. */ 6903 /* Avoid command-line window first character being concealed. */
6903 curwin->w_p_cole = 0; 6904 curwin->w_p_cole = 0;
6904 # endif 6905 # endif
6905 wp = curwin; 6906 wp = curwin;
6906 bp = curbuf; 6907 set_bufref(&bufref, curbuf);
6907 win_goto(old_curwin); 6908 win_goto(old_curwin);
6908 win_close(wp, TRUE); 6909 win_close(wp, TRUE);
6909 6910
6910 /* win_close() may have already wiped the buffer when 'bh' is 6911 /* win_close() may have already wiped the buffer when 'bh' is
6911 * set to 'wipe' */ 6912 * set to 'wipe' */
6912 if (buf_valid(bp)) 6913 if (bufref_valid(&bufref))
6913 close_buffer(NULL, bp, DOBUF_WIPE, FALSE); 6914 close_buffer(NULL, bufref.br_buf, DOBUF_WIPE, FALSE);
6914 6915
6915 /* Restore window sizes. */ 6916 /* Restore window sizes. */
6916 win_size_restore(&winsizes); 6917 win_size_restore(&winsizes);
6917 6918
6918 # ifdef FEAT_AUTOCMD 6919 # ifdef FEAT_AUTOCMD