diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-02-25 19:53:00 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-02-25 19:53:00 +0000 |
commit | 20e31e42626c109b96cb044d39a574ef6f18986e (patch) | |
tree | 2eee449e7a4167a1bc1ec3b3986113b2a1923516 /gcc/vec.c | |
parent | 7b7f33670b97cb646d94435df4e390e4f9264bd4 (diff) | |
download | gcc-20e31e42626c109b96cb044d39a574ef6f18986e.tar.gz |
2014-02-25 Basile Starynkevitch <basile@starynkevitch.net>
{{merge using svnmerge.py with trunk GCC 4.9 svn
rev.208153. Notice that svn 1.8.8 crashes while doing this, so
merged with svn 1.7.14... All is well compiled.}}
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@208154 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/vec.c')
-rw-r--r-- | gcc/vec.c | 51 |
1 files changed, 16 insertions, 35 deletions
diff --git a/gcc/vec.c b/gcc/vec.c index bd0af2dc4ed..c0cd3386b7a 100644 --- a/gcc/vec.c +++ b/gcc/vec.c @@ -171,46 +171,27 @@ vec_prefix::release_overhead (void) /* Calculate the number of slots to reserve a vector, making sure that - RESERVE slots are free. If EXACT grow exactly, otherwise grow - exponentially. PFX is the control data for the vector. */ + it is of at least DESIRED size by growing ALLOC exponentially. */ unsigned -vec_prefix::calculate_allocation (vec_prefix *pfx, unsigned reserve, - bool exact) +vec_prefix::calculate_allocation_1 (unsigned alloc, unsigned desired) { - unsigned alloc = 0; - unsigned num = 0; - - if (pfx) - { - alloc = pfx->m_alloc; - num = pfx->m_num; - } - else if (!reserve) - gcc_unreachable (); - /* We must have run out of room. */ - gcc_assert (alloc - num < reserve); - - if (exact) - /* Exact size. */ - alloc = num + reserve; + gcc_assert (alloc < desired); + + /* Exponential growth. */ + if (!alloc) + alloc = 4; + else if (alloc < 16) + /* Double when small. */ + alloc = alloc * 2; else - { - /* Exponential growth. */ - if (!alloc) - alloc = 4; - else if (alloc < 16) - /* Double when small. */ - alloc = alloc * 2; - else - /* Grow slower when large. */ - alloc = (alloc * 3 / 2); - - /* If this is still too small, set it to the right size. */ - if (alloc < num + reserve) - alloc = num + reserve; - } + /* Grow slower when large. */ + alloc = (alloc * 3 / 2); + + /* If this is still too small, set it to the right size. */ + if (alloc < desired) + alloc = desired; return alloc; } |