Revamp of the basic layouting algorithm in clang-format.
authorDaniel Jasper <djasper@google.com>
Fri, 1 Feb 2013 11:00:45 +0000 (11:00 +0000)
committerDaniel Jasper <djasper@google.com>
Fri, 1 Feb 2013 11:00:45 +0000 (11:00 +0000)
commit4b866274c3f2566d08877f6f0f78240a133d2f0a
tree06f4327d7d9f262c3b9ddadb4bf9341dcccb7a0e
parent52f0e4e1a06f5abb08152dc4447b1f3a68a4670a
Revamp of the basic layouting algorithm in clang-format.

In order to end up with good solutions, clang-format needs to try
"all" combinations of line breaks, evaluate them and select the
best one. Before, we have done this using a DFS with memoization
and cut-off conditions. However, this approach is very limited
as shown by the huge static initializer in the attachment of
llvm.org/PR14959.

Instead, this new implementation uses a variant of Dijkstra's
algorithm to do a prioritized BFS over the solution space.

Some numbers:
lib/Format/TokenAnnotator.cpp: 1.5s -> 0.15s
Attachment of PR14959: 10min+ (didn't finish) -> 10s

No functional changes intended.

llvm-svn: 174166
clang/lib/Format/Format.cpp