Mercurial > vim
comparison src/spell.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 | f094d4085014 |
children | 695186e11daa |
comparison
equal
deleted
inserted
replaced
9486:b931ed8a6782 | 9487:69ed2c9d34a6 |
---|---|
4176 int i, j; | 4176 int i, j; |
4177 langp_T *lp, *lp2; | 4177 langp_T *lp, *lp2; |
4178 static int recursive = FALSE; | 4178 static int recursive = FALSE; |
4179 char_u *ret_msg = NULL; | 4179 char_u *ret_msg = NULL; |
4180 char_u *spl_copy; | 4180 char_u *spl_copy; |
4181 #ifdef FEAT_AUTOCMD | |
4182 bufref_T bufref; | |
4183 | |
4184 set_bufref(&bufref, wp->w_buffer); | |
4185 #endif | |
4181 | 4186 |
4182 /* We don't want to do this recursively. May happen when a language is | 4187 /* We don't want to do this recursively. May happen when a language is |
4183 * not available and the SpellFileMissing autocommand opens a new buffer | 4188 * not available and the SpellFileMissing autocommand opens a new buffer |
4184 * in which 'spell' is set. */ | 4189 * in which 'spell' is set. */ |
4185 if (recursive) | 4190 if (recursive) |
4276 { | 4281 { |
4277 spell_load_lang(lang); | 4282 spell_load_lang(lang); |
4278 #ifdef FEAT_AUTOCMD | 4283 #ifdef FEAT_AUTOCMD |
4279 /* SpellFileMissing autocommands may do anything, including | 4284 /* SpellFileMissing autocommands may do anything, including |
4280 * destroying the buffer we are using... */ | 4285 * destroying the buffer we are using... */ |
4281 if (!buf_valid(wp->w_buffer)) | 4286 if (!bufref_valid(&bufref)) |
4282 { | 4287 { |
4283 ret_msg = (char_u *)"E797: SpellFileMissing autocommand deleted buffer"; | 4288 ret_msg = (char_u *)"E797: SpellFileMissing autocommand deleted buffer"; |
4284 goto theend; | 4289 goto theend; |
4285 } | 4290 } |
4286 #endif | 4291 #endif |
15559 /* enable spelling locally in the new window */ | 15564 /* enable spelling locally in the new window */ |
15560 set_option_value((char_u*)"spell", TRUE, (char_u*)"", OPT_LOCAL); | 15565 set_option_value((char_u*)"spell", TRUE, (char_u*)"", OPT_LOCAL); |
15561 set_option_value((char_u*)"spl", dummy, spl, OPT_LOCAL); | 15566 set_option_value((char_u*)"spl", dummy, spl, OPT_LOCAL); |
15562 vim_free(spl); | 15567 vim_free(spl); |
15563 | 15568 |
15564 if (!bufempty() || !buf_valid(curbuf)) | 15569 if (!bufempty()) |
15565 return; | 15570 return; |
15566 | 15571 |
15567 spell_dump_compl(NULL, 0, NULL, eap->forceit ? DUMPFLAG_COUNT : 0); | 15572 spell_dump_compl(NULL, 0, NULL, eap->forceit ? DUMPFLAG_COUNT : 0); |
15568 | 15573 |
15569 /* Delete the empty line that we started with. */ | 15574 /* Delete the empty line that we started with. */ |