Avoid one heap allocation when instantiating a TSTreeCursor

This commit is contained in:
Max Brunsfeld 2018-05-16 16:05:08 -07:00
parent 6fc8d9871c
commit e3670be42f
8 changed files with 96 additions and 86 deletions

View file

@ -16,13 +16,13 @@ typedef struct {
TSNode ts_node_new(const TSTree *tree, const Subtree *subtree, Length position, TSSymbol alias) {
return (TSNode) {
{position.bytes, position.extent.row, position.extent.column, alias},
{tree, subtree},
{position.bytes, position.extent.row, position.extent.column, alias}
};
}
static inline TSNode ts_node__null() {
return (TSNode) {{NULL, NULL}, {0, 0, 0, 0}};
return ts_node_new(NULL, NULL, length_zero(), 0);
}
// TSNode - accessors