[llvm] [CodeLayout][NFC] Using MergedVector to avoid extra vector allocations (PR #68724)
Rahman Lavaee via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 11 13:52:01 PDT 2023
================
@@ -516,34 +518,62 @@ struct MergedChain {
NodeIter End3;
};
+/// A wrapper around two concatenated vectors (chains) of jumps.
+struct MergedJumpsT {
+ using JumpIter = std::vector<JumpT *>::const_iterator;
+
+ MergedJumpsT(JumpIter Begin, JumpIter End) : Begin1(Begin), End1(End) {}
+
+ template <typename F> void forEach(const F &Func) const {
+ for (auto It = Begin1; It != End1; It++)
+ Func(*It);
+ for (auto It = Begin2; It != End2; It++)
+ Func(*It);
+ }
+
+ bool empty() const { return Begin1 == End1; }
+
+ void append(JumpIter Begin, JumpIter End) {
+ assert(Begin2 == End2 && "cannot extend MergedJumpsT");
+ Begin2 = Begin;
+ End2 = End;
+ }
+
+private:
+ JumpIter Begin1;
----------------
rlavaee wrote:
Ah, I actually meant `std::array<std::vector<JumpT *>*, 2>`.
https://github.com/llvm/llvm-project/pull/68724
More information about the llvm-commits
mailing list