Skip to content

Commit 8744a4e

Browse files
committed
feat(lib): use const for TSCharacterRanges
1 parent 00674e3 commit 8744a4e

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

cli/generate/src/render.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -983,11 +983,7 @@ impl Generator {
983983
return;
984984
}
985985

986-
add_line!(
987-
self,
988-
"static TSCharacterRange {}[] = {{",
989-
info.constant_name
990-
);
986+
add_line!(self, "const TSCharacterRange {}[] = {{", info.constant_name);
991987

992988
indent!(self);
993989
for (ix, range) in characters.ranges().enumerate() {

lib/src/parser.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,21 +132,21 @@ struct TSLanguage {
132132
const char *name;
133133
};
134134

135-
static inline bool set_contains(TSCharacterRange *ranges, uint32_t len, int32_t lookahead) {
135+
static inline bool set_contains(const TSCharacterRange *ranges, uint32_t len, int32_t lookahead) {
136136
uint32_t index = 0;
137137
uint32_t size = len - index;
138138
while (size > 1) {
139139
uint32_t half_size = size / 2;
140140
uint32_t mid_index = index + half_size;
141-
TSCharacterRange *range = &ranges[mid_index];
141+
const TSCharacterRange *range = &ranges[mid_index];
142142
if (lookahead >= range->start && lookahead <= range->end) {
143143
return true;
144144
} else if (lookahead > range->end) {
145145
index = mid_index;
146146
}
147147
size -= half_size;
148148
}
149-
TSCharacterRange *range = &ranges[index];
149+
const TSCharacterRange *range = &ranges[index];
150150
return (lookahead >= range->start && lookahead <= range->end);
151151
}
152152

0 commit comments

Comments
 (0)