Skip to content

utils_whitespaces is slow #134

@djsmith42

Description

@djsmith42

I recently updated to the latest version from github and noticed on master and develop that whitespace removal is very slow. On files over 1,000 lines, it was taking 10+ seconds to save on my box.

The following patch fixes the performance problem for me, and it seems to work with my very minimal testing.

diff --git a/ftplugin/python/pymode.vim b/ftplugin/python/pymode.vim
index 713bafe..4df9847 100644
--- a/ftplugin/python/pymode.vim
+++ b/ftplugin/python/pymode.vim
@@ -133,7 +133,7 @@ endif
 " Utils {{{

 if pymode#Option('utils_whitespaces')
-    au BufWritePre <buffer> :call setline(1,map(getline(1,"$"),'substitute(v:val,"\\s\\+$","","")'))
+    au BufWritePre <buffer> :%s/\s\+$//e
 endif

 " }}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions