forked from OSchip/llvm-project
[clang-format][NFC] Replace deque with vector
I think the deque was chosen because of a better push_front, but in combination with llvm::reverse the push_back'ed vector should be the better choice. Differential Revision: https://reviews.llvm.org/D115064
This commit is contained in:
parent
99c6b12b92
commit
35493b4560
|
@ -1108,22 +1108,22 @@ private:
|
||||||
/// Applies the best formatting by reconstructing the path in the
|
/// Applies the best formatting by reconstructing the path in the
|
||||||
/// solution space that leads to \c Best.
|
/// solution space that leads to \c Best.
|
||||||
void reconstructPath(LineState &State, StateNode *Best) {
|
void reconstructPath(LineState &State, StateNode *Best) {
|
||||||
std::deque<StateNode *> Path;
|
llvm::SmallVector<StateNode *> Path;
|
||||||
// We do not need a break before the initial token.
|
// We do not need a break before the initial token.
|
||||||
while (Best->Previous) {
|
while (Best->Previous) {
|
||||||
Path.push_front(Best);
|
Path.push_back(Best);
|
||||||
Best = Best->Previous;
|
Best = Best->Previous;
|
||||||
}
|
}
|
||||||
for (auto I = Path.begin(), E = Path.end(); I != E; ++I) {
|
for (const auto &Node : llvm::reverse(Path)) {
|
||||||
unsigned Penalty = 0;
|
unsigned Penalty = 0;
|
||||||
formatChildren(State, (*I)->NewLine, /*DryRun=*/false, Penalty);
|
formatChildren(State, Node->NewLine, /*DryRun=*/false, Penalty);
|
||||||
Penalty += Indenter->addTokenToState(State, (*I)->NewLine, false);
|
Penalty += Indenter->addTokenToState(State, Node->NewLine, false);
|
||||||
|
|
||||||
LLVM_DEBUG({
|
LLVM_DEBUG({
|
||||||
printLineState((*I)->Previous->State);
|
printLineState(Node->Previous->State);
|
||||||
if ((*I)->NewLine) {
|
if (Node->NewLine) {
|
||||||
llvm::dbgs() << "Penalty for placing "
|
llvm::dbgs() << "Penalty for placing "
|
||||||
<< (*I)->Previous->State.NextToken->Tok.getName()
|
<< Node->Previous->State.NextToken->Tok.getName()
|
||||||
<< " on a new line: " << Penalty << "\n";
|
<< " on a new line: " << Penalty << "\n";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue