Skip to content

Commit 7bda0bf

Browse files
committed
Dedupe rbs_loc_add_required_child body
1 parent 1444a23 commit 7bda0bf

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

ext/rbs_extension/location.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,10 @@ static void check_children_cap(rbs_loc *loc) {
5757
}
5858

5959
void rbs_loc_add_required_child(rbs_loc *loc, ID name, range r) {
60-
check_children_cap(loc);
61-
62-
unsigned short i = loc->children->len++;
63-
loc->children->entries[i] = (rbs_loc_entry) {
64-
.name = name,
65-
.rg = rbs_new_loc_range(r),
66-
};
60+
rbs_loc_add_optional_child(loc, name, r);
6761

68-
loc->children->required_p |= 1 << i;
62+
unsigned short last_index = loc->children->len - 1;
63+
loc->children->required_p |= 1 << last_index;
6964
}
7065

7166
void rbs_loc_add_optional_child(rbs_loc *loc, ID name, range r) {

0 commit comments

Comments
 (0)