From 62c4f261874dd44e6cdc6788b4a6bc59f9dfe746 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 7 Nov 2016 02:36:07 +0100 Subject: [PATCH] Minor performance optimization in s:guess (#33) --- plugin/sleuth.vim | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/plugin/sleuth.vim b/plugin/sleuth.vim index 560135e..df8bda4 100644 --- a/plugin/sleuth.vim +++ b/plugin/sleuth.vim @@ -15,10 +15,10 @@ function! s:guess(lines) abort let podcomment = 0 let triplequote = 0 let backtick = 0 + let softtab = repeat(' ', 8) for line in a:lines - - if line =~# '^\s*$' + if !len(line) || line =~# '^\s*$' continue endif @@ -60,7 +60,6 @@ function! s:guess(lines) abort let backtick = 1 endif - let softtab = repeat(' ', 8) if line =~# '^\t' let heuristics.hard += 1 elseif line =~# '^' . softtab @@ -73,7 +72,6 @@ function! s:guess(lines) abort if indent > 1 && get(options, 'shiftwidth', 99) > indent let options.shiftwidth = indent endif - endfor if heuristics.hard && !heuristics.spaces