Mercurial > vim
comparison src/ex_cmds.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 | 7520696c14b0 |
children | fd9727ae3c49 |
comparison
equal
deleted
inserted
replaced
9486:b931ed8a6782 | 9487:69ed2c9d34a6 |
---|---|
3664 int did_set_swapcommand = FALSE; | 3664 int did_set_swapcommand = FALSE; |
3665 #endif | 3665 #endif |
3666 buf_T *buf; | 3666 buf_T *buf; |
3667 bufref_T bufref; | 3667 bufref_T bufref; |
3668 #if defined(FEAT_AUTOCMD) || defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) | 3668 #if defined(FEAT_AUTOCMD) || defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) |
3669 buf_T *old_curbuf = curbuf; | 3669 bufref_T old_curbuf; |
3670 #endif | 3670 #endif |
3671 char_u *free_fname = NULL; | 3671 char_u *free_fname = NULL; |
3672 #ifdef FEAT_BROWSE | 3672 #ifdef FEAT_BROWSE |
3673 char_u *browse_file = NULL; | 3673 char_u *browse_file = NULL; |
3674 #endif | 3674 #endif |
3689 int readfile_flags = 0; | 3689 int readfile_flags = 0; |
3690 int did_inc_redrawing_disabled = FALSE; | 3690 int did_inc_redrawing_disabled = FALSE; |
3691 | 3691 |
3692 if (eap != NULL) | 3692 if (eap != NULL) |
3693 command = eap->do_ecmd_cmd; | 3693 command = eap->do_ecmd_cmd; |
3694 #if defined(FEAT_AUTOCMD) || defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) | |
3695 set_bufref(&old_curbuf, curbuf); | |
3696 #endif | |
3694 | 3697 |
3695 if (fnum != 0) | 3698 if (fnum != 0) |
3696 { | 3699 { |
3697 if (fnum == curbuf->b_fnum) /* file is already being edited */ | 3700 if (fnum == curbuf->b_fnum) /* file is already being edited */ |
3698 return OK; /* nothing to do */ | 3701 return OK; /* nothing to do */ |
3855 BLN_CURBUF | ((flags & ECMD_SET_HELP) ? 0 : BLN_LISTED)); | 3858 BLN_CURBUF | ((flags & ECMD_SET_HELP) ? 0 : BLN_LISTED)); |
3856 #ifdef FEAT_AUTOCMD | 3859 #ifdef FEAT_AUTOCMD |
3857 /* autocommands may change curwin and curbuf */ | 3860 /* autocommands may change curwin and curbuf */ |
3858 if (oldwin != NULL) | 3861 if (oldwin != NULL) |
3859 oldwin = curwin; | 3862 oldwin = curwin; |
3860 old_curbuf = curbuf; | 3863 set_bufref(&old_curbuf, curbuf); |
3861 #endif | 3864 #endif |
3862 } | 3865 } |
3863 if (buf == NULL) | 3866 if (buf == NULL) |
3864 goto theend; | 3867 goto theend; |
3865 if (buf->b_ml.ml_mfp == NULL) /* no memfile yet */ | 3868 if (buf->b_ml.ml_mfp == NULL) /* no memfile yet */ |
3873 (void)buf_check_timestamp(buf, FALSE); | 3876 (void)buf_check_timestamp(buf, FALSE); |
3874 /* Check if autocommands made buffer invalid or changed the current | 3877 /* Check if autocommands made buffer invalid or changed the current |
3875 * buffer. */ | 3878 * buffer. */ |
3876 if (!bufref_valid(&bufref) | 3879 if (!bufref_valid(&bufref) |
3877 #ifdef FEAT_AUTOCMD | 3880 #ifdef FEAT_AUTOCMD |
3878 || curbuf != old_curbuf | 3881 || curbuf != old_curbuf.br_buf |
3879 #endif | 3882 #endif |
3880 ) | 3883 ) |
3881 goto theend; | 3884 goto theend; |
3882 #ifdef FEAT_EVAL | 3885 #ifdef FEAT_EVAL |
3883 if (aborting()) /* autocmds may abort script processing */ | 3886 if (aborting()) /* autocmds may abort script processing */ |
3932 # endif | 3935 # endif |
3933 if (buf == curbuf) /* already in new buffer */ | 3936 if (buf == curbuf) /* already in new buffer */ |
3934 auto_buf = TRUE; | 3937 auto_buf = TRUE; |
3935 else | 3938 else |
3936 { | 3939 { |
3937 if (curbuf == old_curbuf) | 3940 if (curbuf == old_curbuf.br_buf) |
3938 #endif | 3941 #endif |
3939 buf_copy_options(buf, BCO_ENTER); | 3942 buf_copy_options(buf, BCO_ENTER); |
3940 | 3943 |
3941 /* close the link to the current buffer */ | 3944 /* close the link to the current buffer */ |
3942 u_sync(FALSE); | 3945 u_sync(FALSE); |
4194 #endif | 4197 #endif |
4195 | 4198 |
4196 #if defined(HAS_SWAP_EXISTS_ACTION) | 4199 #if defined(HAS_SWAP_EXISTS_ACTION) |
4197 if (swap_exists_action == SEA_QUIT) | 4200 if (swap_exists_action == SEA_QUIT) |
4198 retval = FAIL; | 4201 retval = FAIL; |
4199 handle_swap_exists(old_curbuf); | 4202 handle_swap_exists(&old_curbuf); |
4200 #endif | 4203 #endif |
4201 } | 4204 } |
4202 #ifdef FEAT_AUTOCMD | 4205 #ifdef FEAT_AUTOCMD |
4203 else | 4206 else |
4204 { | 4207 { |