diff options
author | Andrew Pinski <pinskia@physics.uc.edu> | 2003-07-16 18:45:56 +0000 |
---|---|---|
committer | Andrew Pinski <pinskia@gcc.gnu.org> | 2003-07-16 11:45:56 -0700 |
commit | d07605f5703529578edb1c65369fba38ddbff327 (patch) | |
tree | 39a0963ec716fc0d03212b9d1c71114101da5421 /gcc/c-common.h | |
parent | 48addf69eb048d3fc0135244e6dc9ea90ecb1254 (diff) | |
download | gcc-d07605f5703529578edb1c65369fba38ddbff327.zip gcc-d07605f5703529578edb1c65369fba38ddbff327.tar.gz gcc-d07605f5703529578edb1c65369fba38ddbff327.tar.bz2 |
re PR c/10962 (lookup_field is a linear search on a linked list (can be slow if large struct))
2003-07-16 Andrew Pinski <pinskia@physics.uc.edu>
ChangeLog:
PR c/10962
* ggc.h: Add header guards.
* c-decl.c (finish_struct): Sort fields if
number greater than 15 and there are no
anonymous structs/unions.
* c-common.h: Include ggc.h.
(sorted_fields_type): New struct.
(field_decl_cmp): New prototype.
(resort_sorted_fields): New prototype.
(DECL_DECLARES_TYPE_NON_TEMPLATE_P): New macro.
* c-tree.h: (lang_type): Use pointer to sorted_fields_type
as s, removing other fields.
* c-typeck.c (lookup_field): Use s in lang_type.
These were mostly moved from cp/class.c:
* c-common.c (field_decl_cmp): New static function.
(field_decl_cmp): New function.
(resort_sorted_fields): New function.
cp/ChangeLog:
* class.c (field_decl_cmp): Remove.
(resort_field_decl_cmp): Remove.
(resort_sorted_fields): Remove.
(add_fields_to_vec): Rename to ...
(add_fields_to_record_type): this.
(finish_struct_1): Change to be using
sorted_fields_type's fields.
* cp-tree.h (lang_decl): In lang_decl_u3
change sorted_fields to be a pointer to
sorted_fields_type.
(resort_sorted_fields): Remove prototype.
* search.c (lookup_field_1): Change to be using
sorted_fields_type's fields.
From-SVN: r69470
Diffstat (limited to 'gcc/c-common.h')
-rw-r--r-- | gcc/c-common.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/c-common.h b/gcc/c-common.h index 94cf6d2..fd7ce4a 100644 --- a/gcc/c-common.h +++ b/gcc/c-common.h @@ -24,6 +24,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "splay-tree.h" #include "cpplib.h" +#include "ggc.h" /* Usage of TREE_LANG_FLAG_?: 0: COMPOUND_STMT_NO_SCOPE (in COMPOUND_STMT). @@ -223,6 +224,13 @@ struct c_common_identifier GTY(()) extern GTY(()) tree c_global_trees[CTI_MAX]; +/* In a RECORD_TYPE, a sorted array of the fields of the type, not a tree for size reasons. */ +struct sorted_fields_type GTY(()) +{ + int len; + tree GTY((length ("%h.len"))) elts[1]; +}; + /* Mark which labels are explicitly declared. These may be shadowed, and may be referenced from nested functions. */ #define C_DECLARED_LABEL_FLAG(label) TREE_LANG_FLAG_1 (label) @@ -343,6 +351,9 @@ extern void c_finish_while_stmt_cond (tree, tree); enum sw_kind { SW_PARAM = 0, SW_LOCAL, SW_GLOBAL }; extern void shadow_warning (enum sw_kind, const char *, tree); +extern int field_decl_cmp (const void *, const void *); +extern void resort_sorted_fields (void *, void *, gt_pointer_operator, + void *); /* Extra information associated with a DECL. Other C dialects extend this structure in various ways. The C front-end only uses this |