[PATCH] D103113: [lld-macho] Deduplicate fixed-width literals

Thorsten via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 26 07:57:48 PDT 2021


tschuett added a comment.

In D103113#2782094 <https://reviews.llvm.org/D103113#2782094>, @tschuett wrote:

> This does not compile:
>
>   std::vector<String<4>> strings4;
>   strings4.reserve(number_of_4_strings*sizeof(String<4>));
>   for (size_t i = 0, e = isec->data.size() / 4; i < e; ++i) {
>     strings4.emplace_back(String<4>(xxx));
>   }
>   strings4.sort();
>   auto bla = std::unique(strings4.begin(), strings4.end());
>
> The hash map will have a lot of mallocs. I would expect sort + unique to be faster. Maybe even parallel sort.

The emplace loop could even be a memcpy?!? Or do everything in-place?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103113



More information about the llvm-commits mailing list