From 2a8a1b8c6f781aae1d10a0d28b6194c50722e712 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sat, 13 Jun 2015 19:50:38 +0000 Subject: [PATCH] [Statepoints] Skip a vector copy when uniquing values. No functionality change intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239688 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/RewriteStatepointsForGC.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp index 6f6ba72c6e6..21ff55c697e 100644 --- a/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp +++ b/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp @@ -1659,17 +1659,10 @@ static void relocationViaAlloca( /// vector. Doing so has the effect of changing the output of a couple of /// tests in ways which make them less useful in testing fused safepoints. template static void unique_unsorted(SmallVectorImpl &Vec) { - DenseSet Seen; - SmallVector TempVec; - TempVec.reserve(Vec.size()); - for (auto Element : Vec) - TempVec.push_back(Element); - Vec.clear(); - for (auto V : TempVec) { - if (Seen.insert(V).second) { - Vec.push_back(V); - } - } + SmallSet Seen; + Vec.erase(std::remove_if(Vec.begin(), Vec.end(), [&](const T &V) { + return !Seen.insert(V).second; + }), Vec.end()); } /// Insert holders so that each Value is obviously live through the entire -- 2.34.1