From ccef93e887e093503cb17f65050dd440fc1106dd Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Tue, 20 Aug 2019 22:20:39 +0200 Subject: [PATCH] util: micro-optimization of existence check for strchars() --- autoload/airline/util.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autoload/airline/util.vim b/autoload/airline/util.vim index 90807674..962a72c2 100644 --- a/autoload/airline/util.vim +++ b/autoload/airline/util.vim @@ -9,6 +9,7 @@ call airline#init#bootstrap() " can be initialized here as "static" let s:spc = g:airline_symbols.space let s:nomodeline = (v:version > 703 || (v:version == 703 && has("patch438"))) ? '' : '' +let s:has_strchars = exists('*strchars') " TODO: Try to cache winwidth(0) function " e.g. store winwidth per window and access that, only update it, if the size @@ -103,7 +104,7 @@ endif " Compatibility wrapper for strchars, in case this vim version does not " have it natively function! airline#util#strchars(str) - if exists('*strchars') + if s:has_strchars return strchars(a:str) else return strlen(substitute(a:str, '.', 'a', 'g'))