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: reduce strlen() calls


On Friday, July 26, 2002, at 01:14  PM, Andreas Schwab wrote:

Devang Patel <dpatel@apple.com> writes:

|> This simple patch reduces strlen() calls by using write_chars (str, len)
|> instead of write_string (str).

|> Index: cp/mangle.c
|> ===================================================================
|> RCS file: /cvsroot/gcc/gcc/gcc/cp/mangle.c,v
|> retrieving revision 1.56
|> diff -c -3 -p -r1.56 mangle.c
|> *** cp/mangle.c 2 Jul 2002 03:19:22 -0000 1.56
|> --- cp/mangle.c 26 Jul 2002 19:21:23 -0000
|> *************** find_substitution (node)
|> *** 501,507 ****
|> && is_std_substitution (decl, SUBID_ALLOCATOR)
|> && !CLASSTYPE_USE_TEMPLATE (TREE_TYPE (decl)))
|> {
|> ! write_string ("Sa");
|> return 1;
|> }
|>
|> --- 501,507 ----
|> && is_std_substitution (decl, SUBID_ALLOCATOR)
|> && !CLASSTYPE_USE_TEMPLATE (TREE_TYPE (decl)))
|> {
|> ! write_chars ("Sa", 2);
|> return 1;
|> }
|>

IMHO it would be more robust to use a macro that expands to `write_chars
(str, strlen (str))' instead of using plain numbers.
I think, that's what `write_string` macro is doing. But if a string size is
fixed, why run strlen() to measure it?

-Devang


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