[PATCH] D114837: format: Remove redundant calls to guessIsObjC to speed up clang-format on unknown file types

Marek Kurdej via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 18 02:19:48 PST 2022


curdeius added a comment.

I see indeed that this change fixes the superlinear complexity when formatting code from stdin:

  cat test.cpp | time clang-format --style=LLVM
  
  0:01.44 ==   1.44s  //  9 returns
  0:13.17 ==  13s     // 10 returns
  1:56.63 == 116s     // 11 returns
  
  time clang-format --style=LLVM test.cpp
  0.03s-0.05s

And after this change the stdin case takes as much time as with a file.

It's definitely a good change, but I'd like to understand what's the reason, why stdin is handled so much differently?
Have you investigated this?

Also, a sort of performance test (e.g. a test with a timeout) would be nice to have.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114837/new/

https://reviews.llvm.org/D114837



More information about the cfe-commits mailing list