feat(lib): use const for TSCharacterRanges
This commit is contained in:
parent
00674e3162
commit
8744a4e3f2
2 changed files with 4 additions and 8 deletions
|
|
@ -983,11 +983,7 @@ impl Generator {
|
|||
return;
|
||||
}
|
||||
|
||||
add_line!(
|
||||
self,
|
||||
"static TSCharacterRange {}[] = {{",
|
||||
info.constant_name
|
||||
);
|
||||
add_line!(self, "const TSCharacterRange {}[] = {{", info.constant_name);
|
||||
|
||||
indent!(self);
|
||||
for (ix, range) in characters.ranges().enumerate() {
|
||||
|
|
|
|||
|
|
@ -132,13 +132,13 @@ struct TSLanguage {
|
|||
const char *name;
|
||||
};
|
||||
|
||||
static inline bool set_contains(TSCharacterRange *ranges, uint32_t len, int32_t lookahead) {
|
||||
static inline bool set_contains(const TSCharacterRange *ranges, uint32_t len, int32_t lookahead) {
|
||||
uint32_t index = 0;
|
||||
uint32_t size = len - index;
|
||||
while (size > 1) {
|
||||
uint32_t half_size = size / 2;
|
||||
uint32_t mid_index = index + half_size;
|
||||
TSCharacterRange *range = &ranges[mid_index];
|
||||
const TSCharacterRange *range = &ranges[mid_index];
|
||||
if (lookahead >= range->start && lookahead <= range->end) {
|
||||
return true;
|
||||
} else if (lookahead > range->end) {
|
||||
|
|
@ -146,7 +146,7 @@ static inline bool set_contains(TSCharacterRange *ranges, uint32_t len, int32_t
|
|||
}
|
||||
size -= half_size;
|
||||
}
|
||||
TSCharacterRange *range = &ranges[index];
|
||||
const TSCharacterRange *range = &ranges[index];
|
||||
return (lookahead >= range->start && lookahead <= range->end);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue