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:
Max Brunsfeld 2016-11-14 12:15:24 -08:00
parent 11e767bd81
commit 535879a2bd
25 changed files with 268 additions and 263 deletions

View file

@ -38,7 +38,7 @@ typedef unsigned int StackIterateAction;
typedef StackIterateAction (*StackIterateCallback)(void *, TSStateId state,
TreeArray *trees,
size_t tree_count,
uint32_t tree_count,
bool is_done,
bool is_pending);
@ -55,7 +55,7 @@ void ts_stack_delete(Stack *);
/*
* Get the stack's current number of versions.
*/
size_t ts_stack_version_count(const Stack *);
uint32_t ts_stack_version_count(const Stack *);
/*
* Get the state at the top of the given version of the stack. If the stack is
@ -86,7 +86,7 @@ bool ts_stack_push(Stack *, StackVersion, Tree *, bool, TSStateId);
* indicates the index of each revealed version and the trees removed from that
* version.
*/
StackPopResult ts_stack_pop_count(Stack *, StackVersion, size_t count);
StackPopResult ts_stack_pop_count(Stack *, StackVersion, uint32_t count);
StackPopResult ts_stack_iterate(Stack *, StackVersion, StackIterateCallback,
void *);