This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][C++] Save memory and reallocations in name-lookup


Hi,

On Fri, 17 Aug 2012, Jakub Jelinek wrote:
On Fri, Aug 17, 2012 at 06:41:37AM -0500, Gabriel Dos Reis wrote:
I am however concerned with:

  static void
  store_bindings (tree names, VEC(cxx_saved_binding,gc) **old_bindings)
  {
!   static VEC(tree,heap) *bindings_need_stored = NULL;

I would be more comfortable to see the cache be on per-scope (e.g. namespace scope) basis as opposed a blanket global cache stored in a global variable.

It is not any kind of cache. It could be in theory an automatic variable vector pointer, it is only used during that function. The reason why it is static variable instead is just to avoid constant allocation/deallocation of the vector, this way after the first call it will be already allocated (but, upon entry to store_bindings will always be empty).

Why not use stack vector of sufficient size for most cases then? I usually do something like:


      VEC (tree, stack) *bindings_need_stored = VEC_alloc (tree, stack, 32);
      ...
      VEC_free (tree, stack, bindings_need_stored);

if I've measured that 32 (or whatever) is enough for most cases. I don't have a clue about this case though.


Dimitris



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]