Skip to content

Commit 3672da6

Browse files
committed
🎨 Use NULL_SUBTREE constant in a few more places
1 parent 2408e7f commit 3672da6

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/runtime/get_changed_ranges.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ typedef enum {
218218
} IteratorComparison;
219219

220220
IteratorComparison iterator_compare(const Iterator *old_iter, const Iterator *new_iter) {
221-
Subtree old_tree = {.ptr = NULL}, new_tree = {.ptr = NULL};
221+
Subtree old_tree = NULL_SUBTREE, new_tree = NULL_SUBTREE;
222222
uint32_t old_start = 0, new_start = 0;
223223
TSSymbol old_alias_symbol = 0, new_alias_symbol = 0;
224224
iterator_get_visible_state(old_iter, &old_tree, &old_alias_symbol, &old_start);

src/runtime/reusable_node.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ typedef struct {
1212
} ReusableNode;
1313

1414
static inline ReusableNode reusable_node_new() {
15-
return (ReusableNode) {array_new(), (Subtree) {.ptr = NULL}};
15+
return (ReusableNode) {array_new(), NULL_SUBTREE};
1616
}
1717

1818
static inline void reusable_node_clear(ReusableNode *self) {
1919
array_clear(&self->stack);
20-
self->last_external_token.ptr = NULL;
20+
self->last_external_token = NULL_SUBTREE;
2121
}
2222

2323
static inline void reusable_node_reset(ReusableNode *self, Subtree tree) {
@@ -32,7 +32,7 @@ static inline void reusable_node_reset(ReusableNode *self, Subtree tree) {
3232
static inline Subtree reusable_node_tree(ReusableNode *self) {
3333
return self->stack.size > 0
3434
? self->stack.contents[self->stack.size - 1].tree
35-
: (Subtree) { .ptr = NULL };
35+
: NULL_SUBTREE;
3636
}
3737

3838
static inline uint32_t reusable_node_byte_offset(ReusableNode *self) {

src/runtime/stack.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ Stack *ts_stack_new(SubtreePool *subtree_pool) {
375375
array_reserve(&self->node_pool, MAX_NODE_POOL_SIZE);
376376

377377
self->subtree_pool = subtree_pool;
378-
self->base_node = stack_node_new(NULL, (Subtree) {.ptr = NULL}, false, 1, &self->node_pool);
378+
self->base_node = stack_node_new(NULL, NULL_SUBTREE, false, 1, &self->node_pool);
379379
ts_stack_clear(self);
380380

381381
return self;
@@ -682,7 +682,7 @@ void ts_stack_clear(Stack *self) {
682682
array_clear(&self->heads);
683683
array_push(&self->heads, ((StackHead){
684684
.node = self->base_node,
685-
.last_external_token.ptr = NULL,
685+
.last_external_token = NULL_SUBTREE,
686686
.status = StackStatusActive,
687687
.lookahead_when_paused = 0,
688688
}));

0 commit comments

Comments
 (0)