Doing ":set t_Co=256" causes to the color scheme to be
sourced. That's fine when value of t_Co changes, but if
value of t_Co is set to the same value as previous value, it
seems useless.
Sourcing color scheme script can be slow. Attached patch
avoids to re-source colorscheme if t_Co is set to the same
value as it was already.
I noticed this while tweaking my ~/.vimrc. When doing ":so ~/.vimrc",
my color scheme was executed 3 times at each invocation of
":so ~/.vimrc":
- when doing ":set t_Co=256"
- when doing ":syntax on"
- and of course when doing ":colorscheme foobar"
Doing ":unset g:colors_name" at beginning of ~/.vimrc avoids
this. But I also think that the patch can have some value if
some script or user change t_Co.
Regards
-- Dominique
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
Index: option.c
===================================================================
RCS file: /cvsroot/vim/vim7/src/option.c,v
retrieving revision 1.148
diff -c -r1.148 option.c
*** option.c 4 Mar 2009 03:13:35 -0000 1.148
--- option.c 17 Mar 2009 21:29:57 -0000
***************
*** 6022,6036 ****
/* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
if (varp == &T_CCO)
{
! t_colors = atoi((char *)T_CCO);
! if (t_colors <= 1)
{
! if (new_value_alloced)
! vim_free(T_CCO);
! T_CCO = empty_option;
}
- /* We now have a different color setup, initialize it again. */
- init_highlight(TRUE, FALSE);
}
ttest(FALSE);
if (varp == &T_ME)
--- 6022,6044 ----
/* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
if (varp == &T_CCO)
{
! int colors = atoi((char *)T_CCO);
!
! /* Only reinitialize colors if t_Co value has really changed
! * to avoid expensive reload of colorscheme if t_Co is set
! * to the same value multiple times. */
! if (colors != t_colors)
{
! t_colors = colors;
! if (t_colors <= 1)
! {
! if (new_value_alloced)
! vim_free(T_CCO);
! T_CCO = empty_option;
! }
! /* We now have a different color setup, initialize it again. */
! init_highlight(TRUE, FALSE);
}
}
ttest(FALSE);
if (varp == &T_ME)