Skip to content

Commit 859d395

Browse files
committed
Clarify rbs_comment_t naming
1 parent d2d0d72 commit 859d395

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

include/rbs/parser.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ typedef struct rbs_comment_t {
2727
rbs_position_t start;
2828
rbs_position_t end;
2929

30-
size_t line_size;
31-
size_t line_count;
32-
rbs_token_t *tokens;
30+
size_t line_tokens_capacity;
31+
size_t line_tokens_count;
32+
rbs_token_t *line_tokens;
3333

3434
struct rbs_comment_t *next_comment;
3535
} rbs_comment_t;

src/parser.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3145,8 +3145,8 @@ static rbs_ast_comment_t *parse_comment_lines(rbs_parser_t *parser, rbs_comment_
31453145
rbs_buffer_t rbs_buffer;
31463146
rbs_buffer_init(ALLOCATOR(), &rbs_buffer);
31473147

3148-
for (size_t i = 0; i < com->line_count; i++) {
3149-
rbs_token_t tok = com->tokens[i];
3148+
for (size_t i = 0; i < com->line_tokens_count; i++) {
3149+
rbs_token_t tok = com->line_tokens[i];
31503150

31513151
const char *comment_start = parser->rbs_lexer_t->string.start + tok.range.start.byte_pos + hash_bytes;
31523152
size_t comment_bytes = RBS_RANGE_BYTES(tok.range) - hash_bytes;
@@ -3190,23 +3190,23 @@ static rbs_comment_t *comment_get_comment(rbs_comment_t *com, int line) {
31903190
}
31913191

31923192
static void comment_insert_new_line(rbs_allocator_t *allocator, rbs_comment_t *com, rbs_token_t comment_token) {
3193-
if (com->line_count == 0) {
3193+
if (com->line_tokens_count == 0) {
31943194
com->start = comment_token.range.start;
31953195
}
31963196

3197-
if (com->line_count == com->line_size) {
3198-
com->line_size += 10;
3197+
if (com->line_tokens_count == com->line_tokens_capacity) {
3198+
com->line_tokens_capacity += 10;
31993199

3200-
if (com->tokens) {
3201-
rbs_token_t *p = com->tokens;
3202-
com->tokens = rbs_allocator_calloc(allocator, com->line_size, rbs_token_t);
3203-
memcpy(com->tokens, p, sizeof(rbs_token_t) * com->line_count);
3200+
if (com->line_tokens) {
3201+
rbs_token_t *p = com->line_tokens;
3202+
com->line_tokens = rbs_allocator_calloc(allocator, com->line_tokens_capacity, rbs_token_t);
3203+
memcpy(com->line_tokens, p, sizeof(rbs_token_t) * com->line_tokens_count);
32043204
} else {
3205-
com->tokens = rbs_allocator_calloc(allocator, com->line_size, rbs_token_t);
3205+
com->line_tokens = rbs_allocator_calloc(allocator, com->line_tokens_capacity, rbs_token_t);
32063206
}
32073207
}
32083208

3209-
com->tokens[com->line_count++] = comment_token;
3209+
com->line_tokens[com->line_tokens_count++] = comment_token;
32103210
com->end = comment_token.range.end;
32113211
}
32123212

@@ -3217,9 +3217,9 @@ static rbs_comment_t *alloc_comment(rbs_allocator_t *allocator, rbs_token_t comm
32173217
.start = comment_token.range.start,
32183218
.end = comment_token.range.end,
32193219

3220-
.line_size = 0,
3221-
.line_count = 0,
3222-
.tokens = NULL,
3220+
.line_tokens_capacity = 0,
3221+
.line_tokens_count = 0,
3222+
.line_tokens = NULL,
32233223

32243224
.next_comment = last_comment,
32253225
};

0 commit comments

Comments
 (0)