From 13642a91a90aa53453d29219c3375ba8ec1abde9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20K=C3=A4chele?= Date: Sat, 15 Nov 2025 16:29:31 +0100 Subject: [PATCH] Use hb_array_first/last --- src/analyze.c | 10 +++++----- src/parser.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/analyze.c b/src/analyze.c index 57f325e6d..fe82b658a 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -288,7 +288,7 @@ static AST_NODE_T* create_control_node( if (end_node) { end_position = end_node->base.location.end; } else if (children && hb_array_size(children) > 0) { - AST_NODE_T* last_child = hb_array_get(children, hb_array_size(children) - 1); + AST_NODE_T* last_child = hb_array_last(children); end_position = last_child->location.end; } else if (subsequent) { end_position = subsequent->location.end; @@ -695,10 +695,10 @@ static size_t process_control_structure( } else if (else_clause) { end_position = else_clause->base.location.end; } else if (hb_array_size(when_conditions) > 0) { - AST_NODE_T* last_when = hb_array_get(when_conditions, hb_array_size(when_conditions) - 1); + AST_NODE_T* last_when = hb_array_last(when_conditions); end_position = last_when->location.end; } else if (hb_array_size(in_conditions) > 0) { - AST_NODE_T* last_in = hb_array_get(in_conditions, hb_array_size(in_conditions) - 1); + AST_NODE_T* last_in = hb_array_last(in_conditions); end_position = last_in->location.end; } @@ -955,7 +955,7 @@ static size_t process_control_structure( if (end_node) { end_position = end_node->base.location.end; } else if (children && hb_array_size(children) > 0) { - AST_NODE_T* last_child = hb_array_get(children, hb_array_size(children) - 1); + AST_NODE_T* last_child = hb_array_last(children); end_position = last_child->location.end; } @@ -1139,7 +1139,7 @@ static size_t process_block_children( hb_array_T* temp_array = hb_array_init(1); size_t new_index = process_control_structure(node, array, index, temp_array, context, child_type); - if (hb_array_size(temp_array) > 0) { hb_array_append(children_array, hb_array_get(temp_array, 0)); } + if (hb_array_size(temp_array) > 0) { hb_array_append(children_array, hb_array_first(temp_array)); } hb_array_free(&temp_array); diff --git a/src/parser.c b/src/parser.c index 03cfebdfd..422b92552 100644 --- a/src/parser.c +++ b/src/parser.c @@ -315,8 +315,8 @@ static AST_HTML_ATTRIBUTE_NAME_NODE_T* parser_parse_html_attribute_name(parser_T position_T node_end = { 0 }; if (children->size > 0) { - AST_NODE_T* first_child = hb_array_get(children, 0); - AST_NODE_T* last_child = hb_array_get(children, children->size - 1); + AST_NODE_T* first_child = hb_array_first(children); + AST_NODE_T* last_child = hb_array_last(children); node_start = first_child->location.start; node_end = last_child->location.end;