]> gcc.gnu.org Git - gcc.git/commit
libstdc++: Optimize std::seed_seq construction
authorAntony Polukhin <antoshkka@gmail.com>
Tue, 17 Aug 2021 12:50:53 +0000 (13:50 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 17 Aug 2021 15:53:19 +0000 (16:53 +0100)
commit174f9257a75dec93221eca26c236e0a6346c9dfd
tree6fc0349205f903bfe82210a028baea03c4ecbe2a
parent897a15f355632bdc31871554892eca5512b3c370
libstdc++: Optimize std::seed_seq construction

When std::seed_seq is constructed from random access iterators we can
detect the internal vector size in O(1). Reserving memory for elements
in such cases may avoid multiple memory allocations.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/random.tcc (seed_seq::seed_seq): Reserve capacity
if distance is O(1).
* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error
line number.

Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/include/bits/random.tcc
libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc
This page took 0.05857 seconds and 5 git commands to generate.