Represent byte, char and tree counts as 32 bit numbers
The parser spends the majority of its time allocating and freeing trees and stack nodes. Also, the memory footprint of the AST is a significant concern when using tree-sitter with large files. This library is already unlikely to work very well with source files larger than 4GB, so representing rows, columns, byte lengths and child indices as unsigned 32 bit integers seems like the right choice.
This commit is contained in:
parent
11e767bd81
commit
535879a2bd
25 changed files with 268 additions and 263 deletions
|
|
@ -80,7 +80,7 @@ void ts_document_edit(TSDocument *self, TSInputEdit edit) {
|
|||
if (!self->tree)
|
||||
return;
|
||||
|
||||
size_t max_bytes = ts_tree_total_bytes(self->tree);
|
||||
uint32_t max_bytes = ts_tree_total_bytes(self->tree);
|
||||
if (edit.start_byte > max_bytes)
|
||||
return;
|
||||
if (edit.bytes_removed > max_bytes - edit.start_byte)
|
||||
|
|
@ -90,7 +90,7 @@ void ts_document_edit(TSDocument *self, TSInputEdit edit) {
|
|||
}
|
||||
|
||||
void ts_document_parse_and_get_changed_ranges(TSDocument *self, TSRange **ranges,
|
||||
size_t *range_count) {
|
||||
uint32_t *range_count) {
|
||||
if (ranges) *ranges = NULL;
|
||||
if (range_count) *range_count = 0;
|
||||
|
||||
|
|
@ -137,6 +137,6 @@ TSNode ts_document_root_node(const TSDocument *self) {
|
|||
return result;
|
||||
}
|
||||
|
||||
size_t ts_document_parse_count(const TSDocument *self) {
|
||||
uint32_t ts_document_parse_count(const TSDocument *self) {
|
||||
return self->parse_count;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue