diff --git a/clang/lib/Format/FormatToken.cpp b/clang/lib/Format/FormatToken.cpp index 59d6f29bb54d27..40aa8f5cacb251 100644 --- a/clang/lib/Format/FormatToken.cpp +++ b/clang/lib/Format/FormatToken.cpp @@ -186,6 +186,9 @@ void CommaSeparatedList::precomputeFormattingInfos(const FormatToken *Token) { // The lengths of an item if it is put at the end of the line. This includes // trailing comments which are otherwise ignored for column alignment. SmallVector EndOfLineItemLength; + MustBreakBeforeItem.reserve(Commas.size() + 1); + EndOfLineItemLength.reserve(Commas.size() + 1); + ItemLengths.reserve(Commas.size() + 1); bool HasSeparatingComment = false; for (unsigned i = 0, e = Commas.size() + 1; i != e; ++i) { diff --git a/clang/lib/Format/TokenAnalyzer.cpp b/clang/lib/Format/TokenAnalyzer.cpp index 348da1f03f2997..0a775c0a87eda7 100644 --- a/clang/lib/Format/TokenAnalyzer.cpp +++ b/clang/lib/Format/TokenAnalyzer.cpp @@ -116,6 +116,7 @@ std::pair TokenAnalyzer::process() { const auto &Lines = UnwrappedLines[Run]; LLVM_DEBUG(llvm::dbgs() << "Run " << Run << "...\n"); SmallVector AnnotatedLines; + AnnotatedLines.reserve(Lines.size()); TokenAnnotator Annotator(Style, Lex.getKeywords()); for (const UnwrappedLine &Line : Lines) {