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]

speed up ggc_alloc_string


Description : function ggc_alloc_string in stringpool.c has a special case
when being passed an empty string
("") as a parameter. I think it is useless. My previous patch remove the
only place in the compiler where an empty string is passed.
More over, even if an empty string is passed, and the special case removed,
the result will not be wrong (just a few bytes in the obstack will have been
wasted).

This patch remove 201437 useless tests (if length == 0) when doing a full
bootstrap.

I'm also wondering if special cases '0' .. '9' are usefull. These cases do
happen but they are very limited.



Bootstrap on a cygwin machine based on snapshot from 20050130.


2005-02-08  Christophe Jaillet <christophe.jaillet@wanadoo.fr>

    * stringpool.c (ggc_alloc_string): Remove a special case for empty
string that never trigger



*** gcc-4.0-20050130/gcc/stringpool.c Wed Jun  9 22:10:10 2004
--- my_patch/stringpool.c Tue Feb  8 23:44:46 2005
*************** ggc_alloc_string (const char *contents,
*** 88,95 ****
    if (length == -1)
      length = strlen (contents);

-   if (length == 0)
-     return empty_string;
    if (length == 1 && ISDIGIT (contents[0]))
      return digit_string (contents[0] - '0');

--- 88,93 ----





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