]> granicus.if.org Git - llvm/commitdiff
[profiledata] Avoid creating a temporary vector in getNumValueData
authorAlexander Shaposhnikov <shal1t712@gmail.com>
Wed, 5 Jul 2017 01:20:52 +0000 (01:20 +0000)
committerAlexander Shaposhnikov <shal1t712@gmail.com>
Wed, 5 Jul 2017 01:20:52 +0000 (01:20 +0000)
getValueSitesForKind returns ArrayRef which has a cast operator
to std::vector, as a result a temporary vector is created
if the type of the variable is const std::vector&
that is suboptimal in this case.

Differential revision: https://reviews.llvm.org/D34970

Test plan: make check-all

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307113 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ProfileData/InstrProf.h

index a6b2850ccd2287164d019f4ccb9bdbae06ac5862..234c2fbeb0328b4a29cb0716a78c37995d8ee211 100644 (file)
@@ -753,11 +753,8 @@ uint32_t InstrProfRecord::getNumValueKinds() const {
 
 uint32_t InstrProfRecord::getNumValueData(uint32_t ValueKind) const {
   uint32_t N = 0;
-  const std::vector<InstrProfValueSiteRecord> &SiteRecords =
-      getValueSitesForKind(ValueKind);
-  for (auto &SR : SiteRecords) {
+  for (auto &SR : getValueSitesForKind(ValueKind))
     N += SR.ValueData.size();
-  }
   return N;
 }