[clang] 36229fa - [clang-format][NFC] Replace most of std::vector with SmallVector
via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 13 16:45:32 PDT 2022
Author: owenca
Date: 2022-07-13T16:45:22-07:00
New Revision: 36229fa3886be7d3c864642fad021c9fe4afda38
URL: https://github.com/llvm/llvm-project/commit/36229fa3886be7d3c864642fad021c9fe4afda38
DIFF: https://github.com/llvm/llvm-project/commit/36229fa3886be7d3c864642fad021c9fe4afda38.diff
LOG: [clang-format][NFC] Replace most of std::vector with SmallVector
Differential Revision: https://reviews.llvm.org/D129466
Added:
Modified:
clang/lib/Format/ContinuationIndenter.cpp
clang/lib/Format/ContinuationIndenter.h
clang/lib/Format/Format.cpp
clang/lib/Format/FormatToken.cpp
clang/lib/Format/Macros.h
clang/lib/Format/UnwrappedLineFormatter.cpp
Removed:
################################################################################
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index e957852ba9859..1cd28ab073da4 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -37,7 +37,7 @@ static bool shouldIndentWrappedSelectorName(const FormatStyle &Style,
// Returns the length of everything up to the first possible line break after
// the ), ], } or > matching \c Tok.
static unsigned getLengthToMatchingParen(const FormatToken &Tok,
- const std::vector<ParenState> &Stack) {
+ const SmallVector<ParenState> &Stack) {
// Normally whether or not a break before T is possible is calculated and
// stored in T.CanBreakBefore. Braces, array initializers and text proto
// messages like `key: < ... >` are an exception: a break is possible
diff --git a/clang/lib/Format/ContinuationIndenter.h b/clang/lib/Format/ContinuationIndenter.h
index 494a9727d5edc..620060e688614 100644
--- a/clang/lib/Format/ContinuationIndenter.h
+++ b/clang/lib/Format/ContinuationIndenter.h
@@ -434,7 +434,7 @@ struct LineState {
/// A stack keeping track of properties applying to parenthesis
/// levels.
- std::vector<ParenState> Stack;
+ SmallVector<ParenState> Stack;
/// Ignore the stack of \c ParenStates for state comparison.
///
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 9ce75b66bdc93..d13907faca43f 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -2386,7 +2386,7 @@ class Cleaner : public TokenAnalyzer {
tooling::Replacements generateFixes() {
tooling::Replacements Fixes;
- std::vector<FormatToken *> Tokens;
+ SmallVector<FormatToken *> Tokens;
std::copy(DeletedTokens.begin(), DeletedTokens.end(),
std::back_inserter(Tokens));
@@ -2580,7 +2580,7 @@ struct JavaImportDirective {
StringRef Identifier;
StringRef Text;
unsigned Offset;
- std::vector<StringRef> AssociatedCommentLines;
+ SmallVector<StringRef> AssociatedCommentLines;
bool IsStatic;
};
@@ -2983,7 +2983,7 @@ tooling::Replacements sortJavaImports(const FormatStyle &Style, StringRef Code,
llvm::Regex ImportRegex(JavaImportRegexPattern);
SmallVector<StringRef, 4> Matches;
SmallVector<JavaImportDirective, 16> ImportsInBlock;
- std::vector<StringRef> AssociatedCommentLines;
+ SmallVector<StringRef> AssociatedCommentLines;
bool FormattingOff = false;
diff --git a/clang/lib/Format/FormatToken.cpp b/clang/lib/Format/FormatToken.cpp
index 2c0fee6975c2b..832af463206c8 100644
--- a/clang/lib/Format/FormatToken.cpp
+++ b/clang/lib/Format/FormatToken.cpp
@@ -264,7 +264,7 @@ 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).
unsigned MaxItems = Style.ColumnLimit / 3;
- std::vector<unsigned> MinSizeInColumn;
+ SmallVector<unsigned> MinSizeInColumn;
MinSizeInColumn.reserve(MaxItems);
for (unsigned Columns = 1; Columns <= MaxItems; ++Columns) {
ColumnFormat Format;
diff --git a/clang/lib/Format/Macros.h b/clang/lib/Format/Macros.h
index ded792c628701..b26799c20f8c4 100644
--- a/clang/lib/Format/Macros.h
+++ b/clang/lib/Format/Macros.h
@@ -128,7 +128,7 @@ class MacroExpander {
const FormatStyle &Style;
llvm::SpecificBumpPtrAllocator<FormatToken> &Allocator;
IdentifierTable &IdentTable;
- std::vector<std::unique_ptr<llvm::MemoryBuffer>> Buffers;
+ SmallVector<std::unique_ptr<llvm::MemoryBuffer>> Buffers;
llvm::StringMap<Definition> Definitions;
};
diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp b/clang/lib/Format/UnwrappedLineFormatter.cpp
index 55a97addb3b1d..abeb93d237767 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1132,7 +1132,7 @@ class OptimizingLineFormatter : public LineFormatter {
typedef std::pair<OrderedPenalty, StateNode *> QueueItem;
/// The BFS queue type.
- typedef std::priority_queue<QueueItem, std::vector<QueueItem>,
+ typedef std::priority_queue<QueueItem, SmallVector<QueueItem>,
std::greater<QueueItem>>
QueueType;
More information about the cfe-commits
mailing list