[PATCH] D129466: [clang-format][NFC] Replace most of std::vector with SmallVector
owenpan added inline comments. Comment at: clang/lib/Format/ContinuationIndenter.cpp:40 static unsigned getLengthToMatchingParen(const FormatToken &Tok, - const std::vector &Stack) { + const SmallVector &Stack) { // Normally whether or not a break before T is possible is calculated and curdeius wrote: > owenpan wrote: > > curdeius wrote: > > > Sorry for a late comment. I think that in a parameter list, we should use > > > `SmallVectorBase` to avoid changing the type if the inplace element count > > > changes. That's not important now though. > > Hmm. I can't find an example of `SmallVectorBase` in llvm-project sources, > > though. > Typo, it's Impl: https://llvm.org/doxygen/classllvm_1_1SmallVectorImpl.html Good catch, though `ArrayRef` is more appropriate in this case. See https://llvm.org/docs/ProgrammersManual.html#llvm-adt-smallvector-h. Fixed in a7789d6. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D129466/new/ https://reviews.llvm.org/D129466 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D129466: [clang-format][NFC] Replace most of std::vector with SmallVector
curdeius added inline comments. Comment at: clang/lib/Format/ContinuationIndenter.cpp:40 static unsigned getLengthToMatchingParen(const FormatToken &Tok, - const std::vector &Stack) { + const SmallVector &Stack) { // Normally whether or not a break before T is possible is calculated and owenpan wrote: > curdeius wrote: > > Sorry for a late comment. I think that in a parameter list, we should use > > `SmallVectorBase` to avoid changing the type if the inplace element count > > changes. That's not important now though. > Hmm. I can't find an example of `SmallVectorBase` in llvm-project sources, > though. Typo, it's Impl: https://llvm.org/doxygen/classllvm_1_1SmallVectorImpl.html Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D129466/new/ https://reviews.llvm.org/D129466 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D129466: [clang-format][NFC] Replace most of std::vector with SmallVector
owenpan added inline comments. Comment at: clang/lib/Format/ContinuationIndenter.cpp:40 static unsigned getLengthToMatchingParen(const FormatToken &Tok, - const std::vector &Stack) { + const SmallVector &Stack) { // Normally whether or not a break before T is possible is calculated and curdeius wrote: > Sorry for a late comment. I think that in a parameter list, we should use > `SmallVectorBase` to avoid changing the type if the inplace element count > changes. That's not important now though. Hmm. I can't find an example of `SmallVectorBase` in llvm-project sources, though. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D129466/new/ https://reviews.llvm.org/D129466 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D129466: [clang-format][NFC] Replace most of std::vector with SmallVector
curdeius added inline comments. Comment at: clang/lib/Format/ContinuationIndenter.cpp:40 static unsigned getLengthToMatchingParen(const FormatToken &Tok, - const std::vector &Stack) { + const SmallVector &Stack) { // Normally whether or not a break before T is possible is calculated and Sorry for a late comment. I think that in a parameter list, we should use `SmallVectorBase` to avoid changing the type if the inplace element count changes. That's not important now though. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D129466/new/ https://reviews.llvm.org/D129466 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D129466: [clang-format][NFC] Replace most of std::vector with SmallVector
This revision was automatically updated to reflect the committed changes. Closed by commit rG36229fa3886b: [clang-format][NFC] Replace most of std::vector with SmallVector (authored by owenpan). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D129466/new/ https://reviews.llvm.org/D129466 Files: 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 Index: clang/lib/Format/UnwrappedLineFormatter.cpp === --- clang/lib/Format/UnwrappedLineFormatter.cpp +++ clang/lib/Format/UnwrappedLineFormatter.cpp @@ -1132,7 +1132,7 @@ typedef std::pair QueueItem; /// The BFS queue type. - typedef std::priority_queue, + typedef std::priority_queue, std::greater> QueueType; Index: clang/lib/Format/Macros.h === --- clang/lib/Format/Macros.h +++ clang/lib/Format/Macros.h @@ -128,7 +128,7 @@ const FormatStyle &Style; llvm::SpecificBumpPtrAllocator &Allocator; IdentifierTable &IdentTable; - std::vector> Buffers; + SmallVector> Buffers; llvm::StringMap Definitions; }; Index: clang/lib/Format/FormatToken.cpp === --- clang/lib/Format/FormatToken.cpp +++ clang/lib/Format/FormatToken.cpp @@ -264,7 +264,7 @@ // 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 MinSizeInColumn; + SmallVector MinSizeInColumn; MinSizeInColumn.reserve(MaxItems); for (unsigned Columns = 1; Columns <= MaxItems; ++Columns) { ColumnFormat Format; Index: clang/lib/Format/Format.cpp === --- clang/lib/Format/Format.cpp +++ clang/lib/Format/Format.cpp @@ -2386,7 +2386,7 @@ tooling::Replacements generateFixes() { tooling::Replacements Fixes; -std::vector Tokens; +SmallVector Tokens; std::copy(DeletedTokens.begin(), DeletedTokens.end(), std::back_inserter(Tokens)); @@ -2580,7 +2580,7 @@ StringRef Identifier; StringRef Text; unsigned Offset; - std::vector AssociatedCommentLines; + SmallVector AssociatedCommentLines; bool IsStatic; }; @@ -2983,7 +2983,7 @@ llvm::Regex ImportRegex(JavaImportRegexPattern); SmallVector Matches; SmallVector ImportsInBlock; - std::vector AssociatedCommentLines; + SmallVector AssociatedCommentLines; bool FormattingOff = false; Index: clang/lib/Format/ContinuationIndenter.h === --- clang/lib/Format/ContinuationIndenter.h +++ clang/lib/Format/ContinuationIndenter.h @@ -434,7 +434,7 @@ /// A stack keeping track of properties applying to parenthesis /// levels. - std::vector Stack; + SmallVector Stack; /// Ignore the stack of \c ParenStates for state comparison. /// Index: clang/lib/Format/ContinuationIndenter.cpp === --- clang/lib/Format/ContinuationIndenter.cpp +++ clang/lib/Format/ContinuationIndenter.cpp @@ -37,7 +37,7 @@ // 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 &Stack) { + const SmallVector &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 Index: clang/lib/Format/UnwrappedLineFormatter.cpp === --- clang/lib/Format/UnwrappedLineFormatter.cpp +++ clang/lib/Format/UnwrappedLineFormatter.cpp @@ -1132,7 +1132,7 @@ typedef std::pair QueueItem; /// The BFS queue type. - typedef std::priority_queue, + typedef std::priority_queue, std::greater> QueueType; Index: clang/lib/Format/Macros.h === --- clang/lib/Format/Macros.h +++ clang/lib/Format/Macros.h @@ -128,7 +128,7 @@ const FormatStyle &Style; llvm::SpecificBumpPtrAllocator &Allocator; IdentifierTable &IdentTable; - std::vector> Buffers; + SmallVector> Buffers; llvm::StringMap Definitions; }; Index: clang/lib/Format/FormatToken.cpp === --- clang/lib/Format/FormatToken.cpp +++ clang/lib/Format/FormatToken.cpp @@ -264,7 +264,7 @@ // We ca
[PATCH] D129466: [clang-format][NFC] Replace most of std::vector with SmallVector
owenpan created this revision. owenpan added reviewers: curdeius, HazardyKnusperkeks, MyDeveloperDay. owenpan added a project: clang-format. Herald added a project: All. owenpan requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D129466 Files: 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 Index: clang/lib/Format/UnwrappedLineFormatter.cpp === --- clang/lib/Format/UnwrappedLineFormatter.cpp +++ clang/lib/Format/UnwrappedLineFormatter.cpp @@ -1132,7 +1132,7 @@ typedef std::pair QueueItem; /// The BFS queue type. - typedef std::priority_queue, + typedef std::priority_queue, std::greater> QueueType; Index: clang/lib/Format/Macros.h === --- clang/lib/Format/Macros.h +++ clang/lib/Format/Macros.h @@ -130,7 +130,7 @@ const FormatStyle &Style; llvm::SpecificBumpPtrAllocator &Allocator; IdentifierTable &IdentTable; - std::vector> Buffers; + SmallVector> Buffers; llvm::StringMap Definitions; }; Index: clang/lib/Format/FormatToken.cpp === --- clang/lib/Format/FormatToken.cpp +++ clang/lib/Format/FormatToken.cpp @@ -264,7 +264,7 @@ // 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 MinSizeInColumn; + SmallVector MinSizeInColumn; MinSizeInColumn.reserve(MaxItems); for (unsigned Columns = 1; Columns <= MaxItems; ++Columns) { ColumnFormat Format; Index: clang/lib/Format/Format.cpp === --- clang/lib/Format/Format.cpp +++ clang/lib/Format/Format.cpp @@ -2386,7 +2386,7 @@ tooling::Replacements generateFixes() { tooling::Replacements Fixes; -std::vector Tokens; +SmallVector Tokens; std::copy(DeletedTokens.begin(), DeletedTokens.end(), std::back_inserter(Tokens)); @@ -2580,7 +2580,7 @@ StringRef Identifier; StringRef Text; unsigned Offset; - std::vector AssociatedCommentLines; + SmallVector AssociatedCommentLines; bool IsStatic; }; @@ -2983,7 +2983,7 @@ llvm::Regex ImportRegex(JavaImportRegexPattern); SmallVector Matches; SmallVector ImportsInBlock; - std::vector AssociatedCommentLines; + SmallVector AssociatedCommentLines; bool FormattingOff = false; Index: clang/lib/Format/ContinuationIndenter.h === --- clang/lib/Format/ContinuationIndenter.h +++ clang/lib/Format/ContinuationIndenter.h @@ -434,7 +434,7 @@ /// A stack keeping track of properties applying to parenthesis /// levels. - std::vector Stack; + SmallVector Stack; /// Ignore the stack of \c ParenStates for state comparison. /// Index: clang/lib/Format/ContinuationIndenter.cpp === --- clang/lib/Format/ContinuationIndenter.cpp +++ clang/lib/Format/ContinuationIndenter.cpp @@ -37,7 +37,7 @@ // 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 &Stack) { + const SmallVector &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 Index: clang/lib/Format/UnwrappedLineFormatter.cpp === --- clang/lib/Format/UnwrappedLineFormatter.cpp +++ clang/lib/Format/UnwrappedLineFormatter.cpp @@ -1132,7 +1132,7 @@ typedef std::pair QueueItem; /// The BFS queue type. - typedef std::priority_queue, + typedef std::priority_queue, std::greater> QueueType; Index: clang/lib/Format/Macros.h === --- clang/lib/Format/Macros.h +++ clang/lib/Format/Macros.h @@ -130,7 +130,7 @@ const FormatStyle &Style; llvm::SpecificBumpPtrAllocator &Allocator; IdentifierTable &IdentTable; - std::vector> Buffers; + SmallVector> Buffers; llvm::StringMap Definitions; }; Index: clang/lib/Format/FormatToken.cpp === --- clang/lib/Format/FormatToken.cpp +++ clang/lib/Format/FormatToken.cpp @@ -264,7