[PATCH] D39214: [MachineModuleInfoImpls] Replace qsort with array_pod_sort

Mandeep Singh Grang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 26 09:05:13 PDT 2017


mgrang added inline comments.


================
Comment at: lib/CodeGen/MachineModuleInfoImpls.cpp:29
 
-static int SortSymbolPair(const void *LHS, const void *RHS) {
-  using PairTy = std::pair<MCSymbol *, MachineModuleInfoImpl::StubValueTy>;
-
-  const MCSymbol *LHSS = ((const PairTy *)LHS)->first;
-  const MCSymbol *RHSS = ((const PairTy *)RHS)->first;
-  return LHSS->getName().compare(RHSS->getName());
+using PairTy = std::pair<MCSymbol *, MachineModuleInfoImpl::StubValueTy>;
+static int SortSymbolPair(const PairTy *LHS, const PairTy *RHS) {
----------------
bkramer wrote:
> Any reason for moving this using decl out of the function?
I think the casts from void * to PairTy * and then saving to MCSymbol were not really needed. So I moved the using decl outside and use it in the function signature. This simplifies the sorting function.


================
Comment at: lib/CodeGen/MachineModuleInfoImpls.cpp:38
 
   if (!List.empty())
+    array_pod_sort(List.begin(), List.end(), SortSymbolPair);
----------------
bkramer wrote:
> Nit: array_pod_sort checks for empty, so this if isn't necessary anymore.
Will remove this check.


Repository:
  rL LLVM

https://reviews.llvm.org/D39214





More information about the llvm-commits mailing list