When sorting the known prefixes after length the if in the loop will hit at most once, so we can return from there.
Also replace the inner loop with an algorithm, that makes it more readable.
Differential D95081
[clang-format] [NFC] Restructure getLineCommentIndentPrefix HazardyKnusperkeks on Jan 20 2021, 12:52 PM. Authored by
Details When sorting the known prefixes after length the if in the loop will hit at most once, so we can return from there. Also replace the inner loop with an algorithm, that makes it more readable.
Diff Detail
Event Timeline
Comment Actions Now with assert. We could do a static_assert, but then we would have to write our own is_sorted, since the std is only constexpr in C++20. Comment Actions Just an assert is ok IMO. We may fix it when LLVM will be compiled with C++20 but this code may change before it happens. |
I'd rather put asserts instead of this comment.