[PATCH] D14786: [llvm-profdata] Add merge() to InstrProfRecord

Sean Silva via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 18 21:30:03 PST 2015


silvas added a subscriber: silvas.

================
Comment at: lib/ProfileData/InstrProfWriter.cpp:104
@@ -129,10 +103,3 @@
 
-  auto Where = ProfileDataMap.find(I.Hash);
-  if (Where == ProfileDataMap.end()) {
-    // We've never seen a function with this name and hash, add it.
-    ProfileDataMap[I.Hash] = I;
-
-    // We keep track of the max function count as we go for simplicity.
-    if (I.Counts[0] > MaxFunctionCount)
-      MaxFunctionCount = I.Counts[0];
-    return instrprof_error::success;
+  auto InsertResult = ProfileDataMap.insert(std::make_pair(I.Hash, I));
+  InstrProfRecord &Dest = InsertResult.first->second;
----------------
davidxl wrote:
> use std:make_pair(I.hash, InstrProfRecord()) to avoid side effect of making copies.
small style nit: use std::tie to make this more readable.


http://reviews.llvm.org/D14786





More information about the llvm-commits mailing list