diff options
author | Trevor Saunders <tbsaunde+gcc@tbsaunde.org> | 2017-05-14 00:38:35 +0000 |
---|---|---|
committer | Trevor Saunders <tbsaunde@gcc.gnu.org> | 2017-05-14 00:38:35 +0000 |
commit | a5c9f2b736f0d152289628e2ff14d1888b512244 (patch) | |
tree | 0234dc61e7e025e37e28cf53905d52df3be73340 /gcc/vec.h | |
parent | 4b5c84f497a052cdba704492d4a4a46e21264779 (diff) | |
download | gcc-a5c9f2b736f0d152289628e2ff14d1888b512244.zip gcc-a5c9f2b736f0d152289628e2ff14d1888b512244.tar.gz gcc-a5c9f2b736f0d152289628e2ff14d1888b512244.tar.bz2 |
allow constructing a auto_vec with a preallocation, and a possibly larger actual allocation size
This allows us to set the capacity of the vector when we construct it,
and still use a stack buffer when the size is small enough.
gcc/ChangeLog:
2017-05-13 Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
* genrecog.c (int_set::int_set): Explicitly construct our
auto_vec base class.
* vec.h (auto_vec::auto_vec): New constructor.
From-SVN: r248019
Diffstat (limited to 'gcc/vec.h')
-rw-r--r-- | gcc/vec.h | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -1272,6 +1272,18 @@ public: this->m_vec = &m_auto; } + auto_vec (size_t s) + { + if (s > N) + { + this->create (s); + return; + } + + m_auto.embedded_init (MAX (N, 2), 0, 1); + this->m_vec = &m_auto; + } + ~auto_vec () { this->release (); |