r239604 - [clang-format] Hoist vector allocation out of loop. NFC.
Benjamin Kramer
benny.kra at GOOGLEMAIL.com
Fri Jun 12 06:06:57 PDT 2015
Author: d0k
Date: Fri Jun 12 08:06:57 2015
New Revision: 239604
URL: http://llvm.org/viewvc/llvm-project?rev=239604&view=rev
Log:
[clang-format] Hoist vector allocation out of loop. NFC.
Modified:
cfe/trunk/lib/Format/FormatToken.cpp
Modified: cfe/trunk/lib/Format/FormatToken.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.cpp?rev=239604&r1=239603&r2=239604&view=diff
==============================================================================
--- cfe/trunk/lib/Format/FormatToken.cpp (original)
+++ cfe/trunk/lib/Format/FormatToken.cpp Fri Jun 12 08:06:57 2015
@@ -203,11 +203,14 @@ void CommaSeparatedList::precomputeForma
// 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;
More information about the cfe-commits
mailing list