]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Small make_tree_vector_from_ctor improvement
authorJakub Jelinek <jakub@redhat.com>
Thu, 23 Jan 2025 22:06:07 +0000 (23:06 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 23 Jan 2025 22:06:07 +0000 (23:06 +0100)
commit4ce9e35396205ee1674658a9b844ccdf80044378
treeef2819772eb0c03688e6118747c10421bf51c0f6
parentce28eb9f91e39a95a499eea36865e394c2bf614b
c++: Small make_tree_vector_from_ctor improvement

After committing the append_ctor_to_tree_vector patch, I've realized
that for the larger constructors make_tree_vector_from_ctor unnecessarily
wastes one GC vector; make_tree_vector () / release_tree_vector () only
caches GC vectors from 4 to 16 allocated tree elements, so in the likely
case of a rather small ctor using make_tree_vector () can be beneficial,
we can pick something from the cache and if we don't need it later,
pt.cc calls release_tree_vector on it to return it back to the cache.
But for the larger ctors, we just eat one vector from the cache, never
use it (because the vec_safe_reserve will immediately allocate a different
vector) and never return it back to the cache.

So, the following patch passes NULL for the larger vectors, which
append_ctor_to_tree_vector handles just fine now (vec_safe_reserve will
just allocate appropriately sized vector).

2025-01-23  Jakub Jelinek  <jakub@redhat.com>

* c-common.cc (make_tree_vector_from_ctor): Only use make_tree_vector
for ctors with <= 16 elements.
gcc/c-family/c-common.cc