From ff55ee7c6d0b6d8c41d35fa543a502f119f56cdd Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Tue, 15 Jun 2004 14:39:28 +0000 Subject: [PATCH] More inlining functions [r3090] --- ir/ident/ident.c | 23 ++++++++++------------- ir/ident/ident_t.h | 23 +++++++++++++++++++++++ 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/ir/ident/ident.c b/ir/ident/ident.c index 3f92131ad..5d6324003 100644 --- a/ir/ident/ident.c +++ b/ir/ident/ident.c @@ -21,25 +21,22 @@ #include #include "ident_t.h" -#include "array.h" -#include "set.h" -static set *id_set; +set *__id_set; void id_init(int initial_n_idents) { - id_set = new_set(memcmp, initial_n_idents); + __id_set = new_set(memcmp, initial_n_idents); } void id_finish (void) { - del_set(id_set); - id_set = NULL; + del_set(__id_set); + __id_set = NULL; } -INLINE ident *id_from_str (const char *str, int len) +ident *(id_from_str)(const char *str, int len) { - assert(len > 0); - return set_hinsert0(id_set, str, len, ID_HASH(str, len)); + return __id_from_str(str, len); } ident *new_id_from_str(const char *str) @@ -48,14 +45,14 @@ ident *new_id_from_str(const char *str) return id_from_str(str, strlen(str)); } -INLINE const char *get_id_str(ident *id) +const char *(get_id_str)(ident *id) { - return (const char *)id->dptr; + return __get_id_str(id); } -INLINE int get_id_strlen(ident *id) +int (get_id_strlen)(ident *id) { - return id->size; + return __get_id_strlen(id); } int id_is_prefix(ident *prefix, ident *id) diff --git a/ir/ident/ident_t.h b/ir/ident/ident_t.h index 0a9df314c..ae48cd986 100644 --- a/ir/ident/ident_t.h +++ b/ir/ident/ident_t.h @@ -14,6 +14,7 @@ # define _IDENT_T_H_ # include "ident.h" +# include "set.h" void id_init (int initial_n_idents); void id_finish (void); @@ -24,4 +25,26 @@ void id_finish (void); + ((unsigned char *)(str))[(len)-1]) * 9 \ + (len)) + +/* ------------------------ * + * inline functions * + * ------------------------ */ +extern set *__id_set; + +static INLINE ident * +__id_from_str(const char *str, int len) +{ + assert(len > 0); + return set_hinsert0(__id_set, str, len, ID_HASH(str, len)); +} + +static INLINE const char * __get_id_str(ident *id) { return (const char *)id->dptr; } + +static INLINE int __get_id_strlen(ident *id) { return id->size; } + + +#define id_from_str(str, len) __id_from_str(str, len) +#define get_id_str(id) __get_id_str(id) +#define get_id_strlen(id) __get_id_strlen(id) + # endif /* _IDENT_T_H_ */ -- 2.20.1