Use a separate type for storing field map headers

This commit is contained in:
Max Brunsfeld 2019-02-08 16:06:29 -08:00
parent 51a9f14f7d
commit d8a2c0dda2
5 changed files with 50 additions and 31 deletions

View file

@ -90,18 +90,12 @@ ts_language_alias_sequence(const TSLanguage *self, uint32_t child_info_id) {
static inline void ts_language_field_map(
const TSLanguage *self,
uint32_t child_info_id,
const TSFieldMapping **start,
const TSFieldMapping **end
const TSFieldMapEntry **start,
const TSFieldMapEntry **end
) {
// To find the field mappings for a given child info id, first index
// into the field map using the child info id directly. This 'header'
// row contains two values:
// * the index where the field mappings start
// * the number of field mappings.
const TSFieldMapping *field_map = self->field_map;
TSFieldMapping header = field_map[child_info_id];
*start = &field_map[header.field_id];
*end = &field_map[header.field_id] + header.child_index;
TSFieldMapSlice slice = self->field_map_slices[child_info_id];
*start = &self->field_map_entries[slice.index];
*end = &self->field_map_entries[slice.index] + slice.length;
}
#ifdef __cplusplus

View file

@ -461,7 +461,7 @@ TSNode ts_node_child_by_field_id(TSNode self, TSFieldId field_id) {
recur:
if (!field_id || ts_node_child_count(self) == 0) return ts_node__null();
const TSFieldMapping *field_map, *field_map_end;
const TSFieldMapEntry *field_map, *field_map_end;
ts_language_field_map(
self.tree->language,
ts_node__subtree(self).ptr->child_info_id,

View file

@ -264,7 +264,7 @@ TSFieldId ts_tree_cursor_current_field_id(const TSTreeCursor *_self) {
}
}
const TSFieldMapping *field_map, *field_map_end;
const TSFieldMapEntry *field_map, *field_map_end;
ts_language_field_map(
self->tree->language,
parent_entry->subtree->ptr->child_info_id,