diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2023-05-25 09:57:46 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2023-05-31 21:01:15 +0100 |
commit | fb409a15d9babc78fe1d9957afcbaf1102cce58f (patch) | |
tree | b597fb9c7e3211c9099661a94a765f54b4cb9f9c /libstdc++-v3/include/std/complex | |
parent | a239a35075ffd8b34f1db72c22998a625ff962b5 (diff) | |
download | gcc-fb409a15d9babc78fe1d9957afcbaf1102cce58f.zip gcc-fb409a15d9babc78fe1d9957afcbaf1102cce58f.tar.gz gcc-fb409a15d9babc78fe1d9957afcbaf1102cce58f.tar.bz2 |
libstdc++: Express std::vector's size() <= capacity() invariant in code
This adds optimizer hints so that GCC knows that size() <= capacity() is
always true. This allows the compiler to optimize away re-allocating
paths when assigning new values to the vector without resizing it, e.g.,
vec.assign(vec.size(), new_val).
libstdc++-v3/ChangeLog:
* include/bits/stl_vector.h (_Vector_base::_M_invariant()): New
function.
(vector::size(), vector::capacity()): Call _M_invariant().
* testsuite/23_containers/vector/capacity/invariant.cc: New test.
* testsuite/23_containers/vector/types/1.cc: Add suppression for
false positive warning (PR110060).
Diffstat (limited to 'libstdc++-v3/include/std/complex')
0 files changed, 0 insertions, 0 deletions