diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2020-04-13 01:48:47 -0400 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2020-04-13 01:48:47 -0400 |
commit | d3df35312cb9caf96ab787a4ee3db2c356060e7e (patch) | |
tree | 2cadc5aa7492db0e742ebcc75a874a8034dbe730 /identifiers.c | |
parent | 3f80b6f659fe7480e537246ea79fbf6a0ec43031 (diff) |
cleaned up struct member access with struct[member_as_string] by replacing it with struct.member
Diffstat (limited to 'identifiers.c')
-rw-r--r-- | identifiers.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/identifiers.c b/identifiers.c index a31600c..b5e3f46 100644 --- a/identifiers.c +++ b/identifiers.c @@ -55,15 +55,20 @@ static inline bool ident_eq_str(Identifier i, const char *s) { return ident_str_eq_str(i->str, s); } + +static inline Identifier ident_insert_with_len(Identifiers *ids, char *s, size_t len) { + IdentSlot *slot = (IdentSlot *)str_hash_table_insert_(&ids->table, s, len); + slot->idents = ids; + return slot; +} + /* moves s to the char after the identifier */ /* inserts if does not exist. reads until non-ident char is found. */ /* advances past identifier */ -static Identifier ident_insert(Identifiers *ids, char **s) { +static inline Identifier ident_insert(Identifiers *ids, char **s) { char *original = *s; size_t len = ident_str_len_advance(s); - IdentSlot *slot = (IdentSlot *)str_hash_table_insert_(&ids->table, original, len); - slot->idents = ids; - return slot; + return ident_insert_with_len(ids, original, len); } static char *ident_to_str(Identifier i) { |