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]

PATCH: reduce strlen() calls


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

Bootstrapped and finished test suite check.

-Devang

2002-07-25 Devang Patel <dpatel@apple.com>
* cp/mangle.c (find_substitution): Use write_chars () instead of write_string.
(write_unscoped_name): Same.
(write_unqualified_name): Same.
(write_special_name_constructor): Same.
(write_special_name_destructor): Same.
(write_type): Same.
(write_expression): Same.
(mangle_special_for_type): Same.
(mangle_ctor_vtbl_for_type): Same.
(mangle_thunk): Same.
(mangle_guard_variable): Same.
(mangle_ref_init_variable): Same.



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;
}

*************** find_substitution (node)
*** 526,532 ****
&& is_std_substitution_char (TREE_VEC_ELT (args, 2),
SUBID_ALLOCATOR))
{
! write_string ("Ss");
return 1;
}
}
--- 526,532 ----
&& is_std_substitution_char (TREE_VEC_ELT (args, 2),
SUBID_ALLOCATOR))
{
! write_chars ("Ss", 2);
return 1;
}
}
*************** find_substitution (node)
*** 534,540 ****
else
/* Substitute for the template name only if this isn't a type. */
{
! write_string ("Sb");
return 1;
}
}
--- 534,540 ----
else
/* Substitute for the template name only if this isn't a type. */
{
! write_chars ("Sb", 2);
return 1;
}
}
*************** find_substitution (node)
*** 558,576 ****
tree name = DECL_NAME (CLASSTYPE_TI_TEMPLATE (type));
if (name == subst_identifiers[SUBID_BASIC_ISTREAM])
{
! write_string ("Si");
return 1;
}
/* Or basic_ostream? */
else if (name == subst_identifiers[SUBID_BASIC_OSTREAM])
{
! write_string ("So");
return 1;
}
/* Or basic_iostream? */
else if (name == subst_identifiers[SUBID_BASIC_IOSTREAM])
{
! write_string ("Sd");
return 1;
}
}
--- 558,576 ----
tree name = DECL_NAME (CLASSTYPE_TI_TEMPLATE (type));
if (name == subst_identifiers[SUBID_BASIC_ISTREAM])
{
! write_chars ("Si", 2);
return 1;
}
/* Or basic_ostream? */
else if (name == subst_identifiers[SUBID_BASIC_OSTREAM])
{
! write_chars ("So", 2);
return 1;
}
/* Or basic_iostream? */
else if (name == subst_identifiers[SUBID_BASIC_IOSTREAM])
{
! write_chars ("Sd", 2);
return 1;
}
}
*************** find_substitution (node)
*** 579,585 ****
/* Check for namespace std. */
if (decl && DECL_NAMESPACE_STD_P (decl))
{
! write_string ("St");
return 1;
}

--- 579,585 ----
/* Check for namespace std. */
if (decl && DECL_NAMESPACE_STD_P (decl))
{
! write_chars ("St", 2);
return 1;
}

*************** write_mangled_name (decl)
*** 625,631 ****
else
/* C++ name; needs to be mangled. */
{
! write_string ("_Z");
write_encoding (decl);
}
}
--- 625,631 ----
else
/* C++ name; needs to be mangled. */
{
! write_chars ("_Z", 2);
write_encoding (decl);
}
}
*************** write_unscoped_name (decl)
*** 775,781 ****
/* Is DECL in ::std? */
if (DECL_NAMESPACE_STD_P (context))
{
! write_string ("St");
write_unqualified_name (decl);
}
/* If not, it should be either in the global namespace, or directly
--- 775,781 ----
/* Is DECL in ::std? */
if (DECL_NAMESPACE_STD_P (context))
{
! write_chars ("St", 2);
write_unqualified_name (decl);
}
/* If not, it should be either in the global namespace, or directly
*************** write_unqualified_name (decl)
*** 997,1003 ****
}
else
type = TREE_TYPE (DECL_NAME (decl));
! write_string ("cv");
write_type (type);
}
else if (DECL_OVERLOADED_OPERATOR_P (decl))
--- 997,1003 ----
}
else
type = TREE_TYPE (DECL_NAME (decl));
! write_chars ("cv", 2);
write_type (type);
}
else if (DECL_OVERLOADED_OPERATOR_P (decl))
*************** write_special_name_constructor (ctor)
*** 1196,1204 ****
old-style destructor, we still have to consider entities
(like static variables) nested inside it. */
|| DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (ctor))
! write_string ("C1");
else if (DECL_BASE_CONSTRUCTOR_P (ctor))
! write_string ("C2");
else
abort ();
}
--- 1196,1204 ----
old-style destructor, we still have to consider entities
(like static variables) nested inside it. */
|| DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (ctor))
! write_chars ("C1", 2);
else if (DECL_BASE_CONSTRUCTOR_P (ctor))
! write_chars ("C2", 2);
else
abort ();
}
*************** write_special_name_destructor (dtor)
*** 1219,1233 ****
tree dtor;
{
if (DECL_DELETING_DESTRUCTOR_P (dtor))
! write_string ("D0");
else if (DECL_COMPLETE_DESTRUCTOR_P (dtor)
/* Even though we don't ever emit a definition of the
old-style destructor, we still have to consider entities
(like static variables) nested inside it. */
|| DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (dtor))
! write_string ("D1");
else if (DECL_BASE_DESTRUCTOR_P (dtor))
! write_string ("D2");
else
abort ();
}
--- 1219,1233 ----
tree dtor;
{
if (DECL_DELETING_DESTRUCTOR_P (dtor))
! write_chars ("D0", 2);
else if (DECL_COMPLETE_DESTRUCTOR_P (dtor)
/* Even though we don't ever emit a definition of the
old-style destructor, we still have to consider entities
(like static variables) nested inside it. */
|| DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (dtor))
! write_chars ("D1", 2);
else if (DECL_BASE_DESTRUCTOR_P (dtor))
! write_chars ("D2", 2);
else
abort ();
}
*************** write_type (type)
*** 1456,1462 ****
break;

case VECTOR_TYPE:
! write_string ("U8__vector");
write_type (TREE_TYPE (type));
break;

--- 1456,1462 ----
break;

case VECTOR_TYPE:
! write_chars ("U8__vector", 10);
write_type (TREE_TYPE (type));
break;

*************** write_expression (expr)
*** 1837,1843 ****
else if (TREE_CODE (expr) == SIZEOF_EXPR
&& TYPE_P (TREE_OPERAND (expr, 0)))
{
! write_string ("st");
write_type (TREE_OPERAND (expr, 0));
}
else
--- 1837,1843 ----
else if (TREE_CODE (expr) == SIZEOF_EXPR
&& TYPE_P (TREE_OPERAND (expr, 0)))
{
! write_chars ("st", 2);
write_type (TREE_OPERAND (expr, 0));
}
else
*************** mangle_special_for_type (type, code)
*** 2310,2316 ****
start_mangling ();

/* Start the mangling. */
! write_string ("_Z");
write_string (code);

/* Add the type. */
--- 2310,2316 ----
start_mangling ();

/* Start the mangling. */
! write_chars ("_Z", 2);
write_string (code);

/* Add the type. */
*************** mangle_ctor_vtbl_for_type (type, binfo)
*** 2384,2391 ****

start_mangling ();

! write_string ("_Z");
! write_string ("TC");
write_type (type);
write_integer_cst (BINFO_OFFSET (binfo));
write_char ('_');
--- 2384,2391 ----

start_mangling ();

! write_chars ("_Z", 2);
! write_chars ("TC", 2);
write_type (type);
write_integer_cst (BINFO_OFFSET (binfo));
write_char ('_');
*************** mangle_thunk (fn_decl, offset, vcall_off
*** 2417,2423 ****

start_mangling ();

! write_string ("_Z");
/* The <special-name> for virtual thunks is Tv, for non-virtual
thunks Th. */
write_char ('T');
--- 2417,2423 ----

start_mangling ();

! write_chars ("_Z", 2);
/* The <special-name> for virtual thunks is Tv, for non-virtual
thunks Th. */
write_char ('T');
*************** mangle_guard_variable (variable)
*** 2494,2500 ****
tree variable;
{
start_mangling ();
! write_string ("_ZGV");
if (strncmp (IDENTIFIER_POINTER (DECL_NAME (variable)), "_ZGR", 4) == 0)
/* The name of a guard variable for a reference temporary should refer
to the reference, not the temporary. */
--- 2494,2500 ----
tree variable;
{
start_mangling ();
! write_chars ("_ZGV", 4);
if (strncmp (IDENTIFIER_POINTER (DECL_NAME (variable)), "_ZGR", 4) == 0)
/* The name of a guard variable for a reference temporary should refer
to the reference, not the temporary. */
*************** mangle_ref_init_variable (variable)
*** 2513,2519 ****
tree variable;
{
start_mangling ();
! write_string ("_ZGR");
write_name (variable, /*ignore_local_scope=*/0);
return get_identifier (finish_mangling ());
}
--- 2513,2519 ----
tree variable;
{
start_mangling ();
! write_chars ("_ZGR", 4);
write_name (variable, /*ignore_local_scope=*/0);
return get_identifier (finish_mangling ());
}


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