[llvm] 7df434e - [TableGen] Avoid vector copy in TreePatter::InlinePatternFragments. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 10 23:02:35 PDT 2023
Author: Craig Topper
Date: 2023-04-10T23:01:15-07:00
New Revision: 7df434e3ffebf5cb8b61c8028a9c53dc91bb60e0
URL: https://github.com/llvm/llvm-project/commit/7df434e3ffebf5cb8b61c8028a9c53dc91bb60e0
DIFF: https://github.com/llvm/llvm-project/commit/7df434e3ffebf5cb8b61c8028a9c53dc91bb60e0.diff
LOG: [TableGen] Avoid vector copy in TreePatter::InlinePatternFragments. NFC
Instead of copying a vector and clearing the original, we can swap
with an empty vector.
Added:
Modified:
llvm/utils/TableGen/CodeGenDAGPatterns.h
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.h b/llvm/utils/TableGen/CodeGenDAGPatterns.h
index 154c9f1ede4db..1fb7100eb4aa3 100644
--- a/llvm/utils/TableGen/CodeGenDAGPatterns.h
+++ b/llvm/utils/TableGen/CodeGenDAGPatterns.h
@@ -948,10 +948,10 @@ class TreePattern {
/// PatFrags references. This may increase the number of trees in the
/// pattern if a PatFrags has multiple alternatives.
void InlinePatternFragments() {
- std::vector<TreePatternNodePtr> Copy = Trees;
- Trees.clear();
- for (unsigned i = 0, e = Copy.size(); i != e; ++i)
- Copy[i]->InlinePatternFragments(Copy[i], *this, Trees);
+ std::vector<TreePatternNodePtr> Copy;
+ Trees.swap(Copy);
+ for (const TreePatternNodePtr &C : Copy)
+ TreePatternNode::InlinePatternFragments(C, *this, Trees);
}
/// InferAllTypes - Infer/propagate as many types throughout the expression
More information about the llvm-commits
mailing list