diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2015-06-12 13:06:57 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2015-06-12 13:06:57 +0000 |
commit | 3aa55db86dbaa8b47e8ee6a08b9af7b9c8b436dd (patch) | |
tree | 478675d34771f793ce6563dff9fa568b67a4a817 /clang/lib/Format/FormatToken.cpp | |
parent | 0b9319edb08819ca21a362783debf00b3471f1ce (diff) | |
download | bcm5719-llvm-3aa55db86dbaa8b47e8ee6a08b9af7b9c8b436dd.tar.gz bcm5719-llvm-3aa55db86dbaa8b47e8ee6a08b9af7b9c8b436dd.zip |
[clang-format] Hoist vector allocation out of loop. NFC.
llvm-svn: 239604
Diffstat (limited to 'clang/lib/Format/FormatToken.cpp')
-rw-r--r-- | clang/lib/Format/FormatToken.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/Format/FormatToken.cpp b/clang/lib/Format/FormatToken.cpp index 88678ca1abe..316171dc189 100644 --- a/clang/lib/Format/FormatToken.cpp +++ b/clang/lib/Format/FormatToken.cpp @@ -203,11 +203,14 @@ void CommaSeparatedList::precomputeFormattingInfos(const FormatToken *Token) { // We can never place more than ColumnLimit / 3 items in a row (because of the // spaces and the comma). - for (unsigned Columns = 1; Columns <= Style.ColumnLimit / 3; ++Columns) { + unsigned MaxItems = Style.ColumnLimit / 3; + std::vector<unsigned> MinSizeInColumn; + MinSizeInColumn.reserve(MaxItems); + for (unsigned Columns = 1; Columns <= MaxItems; ++Columns) { ColumnFormat Format; Format.Columns = Columns; Format.ColumnSizes.resize(Columns); - std::vector<unsigned> MinSizeInColumn(Columns, UINT_MAX); + MinSizeInColumn.assign(Columns, UINT_MAX); Format.LineCount = 1; bool HasRowWithSufficientColumns = false; unsigned Column = 0; |