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] Don't reallocate small almost empty hashtabs on every htab_traverse call


On Fri, Jun 19, 2009 at 11:40:20AM -0400, DJ Delorie wrote:
> 
> > Bootstrapped/regtested on x86_64-linux, ok for trunk?
> 
> Ok.  I wonder if this check could be moved to htab_expand, though?

That would be my first variant (untested yet).  On IRC Richard Guenther
said he prefers the htab_traverse change instead, but I don't really care
either way.

2009-06-19  Jakub Jelinek  <jakub@redhat.com>

	* hashtab.c (htab_expand): Don't do anything if not changing
	hash table size and there are no deleted entries.

--- libiberty/hashtab.c.jj	2008-09-30 16:57:39.000000000 +0200
+++ libiberty/hashtab.c	2009-06-19 13:46:55.000000000 +0200
@@ -1,5 +1,5 @@
 /* An expandable hash tables datatype.  
-   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
+   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2009
    Free Software Foundation, Inc.
    Contributed by Vladimir Makarov (vmakarov@cygnus.com).
 
@@ -516,6 +516,10 @@ htab_expand (htab_t htab)
       nindex = oindex;
       nsize = osize;
     }
+  /* It doesn't make sense to reallocate if size doesn't change and
+     there are no deleted entries.  */
+  if (nsize == osize && htab->n_deleted == 0)
+    return 0;
 
   if (htab->alloc_with_arg_f != NULL)
     nentries = (PTR *) (*htab->alloc_with_arg_f) (htab->alloc_arg, nsize,


	Jakub


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