[PATCH] D129105: [clang-format][NFC] Clean up IndentForLevel in LevelIndentTracker
Owen Pan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 7 15:33:22 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc84d29acbfa6: [clang-format][NFC] Clean up IndentForLevel in LevelIndentTracker (authored by owenpan).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D129105/new/
https://reviews.llvm.org/D129105
Files:
clang/lib/Format/UnwrappedLineFormatter.cpp
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===================================================================
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -59,8 +59,7 @@
Offset = getIndentOffset(*Line.First);
// Update the indent level cache size so that we can rely on it
// having the right size in adjustToUnmodifiedline.
- while (IndentForLevel.size() <= Line.Level)
- IndentForLevel.push_back(-1);
+ skipLine(Line, /*UnknownIndent=*/true);
if (Line.InPPDirective) {
unsigned IndentWidth =
(Style.PPIndentWidth >= 0) ? Style.PPIndentWidth : Style.IndentWidth;
@@ -76,9 +75,9 @@
/// Update the indent state given that \p Line indent should be
/// skipped.
- void skipLine(const AnnotatedLine &Line) {
- while (IndentForLevel.size() <= Line.Level)
- IndentForLevel.push_back(Indent);
+ void skipLine(const AnnotatedLine &Line, bool UnknownIndent = false) {
+ if (Line.Level >= IndentForLevel.size())
+ IndentForLevel.resize(Line.Level + 1, UnknownIndent ? -1 : Indent);
}
/// Update the level indent to adapt to the given \p Line.
@@ -159,7 +158,7 @@
const unsigned AdditionalIndent;
/// The indent in characters for each level.
- std::vector<int> IndentForLevel;
+ SmallVector<int> IndentForLevel;
/// Offset of the current line relative to the indent level.
///
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129105.443078.patch
Type: text/x-patch
Size: 1430 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220707/05cf2f69/attachment.bin>
More information about the cfe-commits
mailing list