[PATCH] D47492: DWARFUnit::m_die_array swap()->shrink_to_fit()

Jan Kratochvil via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 31 02:10:45 PDT 2018


jankratochvil added a comment.

In https://reviews.llvm.org/D47492#1117350, @labath wrote:

> it is implemented (in libstdc++ at least) using the swap trick too.


Thanks for the heads up, I expected it does `realloc()`: implementation absolutely cannot rely on realloc ... because realloc, if it cannot shrink in-place, will either leave the memory alone (no-op case) or make a bitwise copy (and miss the opportunity for readjusting pointers, etc. that the proper C++ copying/moving constructors would give) <https://stackoverflow.com/a/23513877/2995591>


Repository:
  rL LLVM

https://reviews.llvm.org/D47492





More information about the llvm-commits mailing list