[llvm] 2ecb1b6 - [PostOrderIterator] Use SmallVector for RPOT blocks (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue May 23 05:28:46 PDT 2023
Author: Nikita Popov
Date: 2023-05-23T14:28:38+02:00
New Revision: 2ecb1b6d274792d158e0f9f2141766651ffe27bc
URL: https://github.com/llvm/llvm-project/commit/2ecb1b6d274792d158e0f9f2141766651ffe27bc
DIFF: https://github.com/llvm/llvm-project/commit/2ecb1b6d274792d158e0f9f2141766651ffe27bc.diff
LOG: [PostOrderIterator] Use SmallVector for RPOT blocks (NFC)
Added:
Modified:
llvm/include/llvm/ADT/PostOrderIterator.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/PostOrderIterator.h b/llvm/include/llvm/ADT/PostOrderIterator.h
index 73f6feaf1919..d13a53f38290 100644
--- a/llvm/include/llvm/ADT/PostOrderIterator.h
+++ b/llvm/include/llvm/ADT/PostOrderIterator.h
@@ -296,23 +296,24 @@ template<class GraphT, class GT = GraphTraits<GraphT>>
class ReversePostOrderTraversal {
using NodeRef = typename GT::NodeRef;
- std::vector<NodeRef> Blocks; // Block list in normal PO order
+ using VecTy = SmallVector<NodeRef, 8>;
+ VecTy Blocks; // Block list in normal PO order
void Initialize(const GraphT &G) {
std::copy(po_begin(G), po_end(G), std::back_inserter(Blocks));
}
public:
- using rpo_iterator = typename std::vector<NodeRef>::reverse_iterator;
- using const_rpo_iterator = typename std::vector<NodeRef>::const_reverse_iterator;
+ using rpo_iterator = typename VecTy::reverse_iterator;
+ using const_rpo_iterator = typename VecTy::const_reverse_iterator;
ReversePostOrderTraversal(const GraphT &G) { Initialize(G); }
// Because we want a reverse post order, use reverse iterators from the vector
rpo_iterator begin() { return Blocks.rbegin(); }
- const_rpo_iterator begin() const { return Blocks.crbegin(); }
+ const_rpo_iterator begin() const { return Blocks.rbegin(); }
rpo_iterator end() { return Blocks.rend(); }
- const_rpo_iterator end() const { return Blocks.crend(); }
+ const_rpo_iterator end() const { return Blocks.rend(); }
};
} // end namespace llvm
More information about the llvm-commits
mailing list