[PATCH] D100451: [NFC] Fix unused variable warning.

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 24 18:04:29 PDT 2021


dblaikie added inline comments.


================
Comment at: lld/COFF/Chunks.cpp:818-821
+  (void)eq;
   std::sort(begin, begin + cnt, lt);
   assert(std::unique(begin, begin + cnt, eq) == begin + cnt &&
          "RVA tables should be de-duplicated");
----------------
dblaikie wrote:
> Rather than void casting the lambda, it's probably better to roll the lambda into the usage:
> ```
> assert(std::unique(begin, begin + cnt, [](const RVAFlag &a, const RVAFlag &b) { return a.rva == b.rva; }) == begin + cnt && "...");
> ```
> 
> Also the lt lambda could be rolled into the std::sort call as well.
> 
> And perhaps making begin+cnt into an ArrayRef might be nice too. (then this code could use llvm::sort(container, comparator) for convenience - I don't think there's an llvm::unique that takes a container yet - but maybe someone will add one)
> 
Ended up doing a few cleanups in e5b66a373414036db22d19647d913c2571df2701


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100451/new/

https://reviews.llvm.org/D100451



More information about the llvm-commits mailing list