Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the source file much longer, the :ClangFormat runs much longer #85

Open
buptjamin opened this issue May 12, 2019 · 3 comments
Open

the source file much longer, the :ClangFormat runs much longer #85

buptjamin opened this issue May 12, 2019 · 3 comments

Comments

@buptjamin
Copy link

slow problem when the source file was long/big.
for example: any source file 1000+ lines

@buptjamin
Copy link
Author

use https://github.com/google/vim-codefmt now!

@rhysd
Copy link
Owner

rhysd commented May 15, 2019

vim-codefmt also overwrites entire buffer with formatted output. So I don't know what causes the performance issue on your environment. https://github.com/google/vim-codefmt/blob/master/autoload/codefmt/clangformat.vim#L121

Please let me know the pre-condition (OS, Vim version) and how to reproduce it if you're still interested in this plugin. Otherwise I will close this issue since I cannot investigate further.

@Kypert
Copy link

Kypert commented Apr 11, 2020

Switched to google/vim-codefmt for a while, but wanted to come back to this plugin. Culprit in my case seems to have been foldmethod=syntax, please see investigation below.

Using my casual +10k lines C-file, I started the profiler to see what took time:

FUNCTIONS SORTED ON TOTAL TIME
count  total (s)   self (s)  function
    1  17.694369  16.049015  clang_format#replace()
    1   1.645128   0.003329  clang_format#format()
    1   1.641716   0.000726  <SNR>74_system()
...

In clang_format#replace(), the call to setline(1, splitted) took about 16s.

Found a similar issue on setline() here dense-analysis/ale#1829.

By installing Konfekt/FastFold, the time spent in clang_format#replace() went down to 0.006350s.

If I understand correctly, google/vim-codefmt does replace the buffer too (maktaba#buffer#Overwrite()), but in my case I ended up using the python implementation to work on the diff-chunk, avoiding their call to setline().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants