mirror of
https://github.com/tree-sitter/tree-sitter.git
synced 2026-09-10 07:36:22 -04:00
query: Use uint32_t for capture list IDs
This commit is contained in:
parent
cd96552448
commit
1f6eac555c
|
|
@ -801,16 +801,12 @@ void ts_query_cursor_exec(TSQueryCursor *, const TSQuery *, TSNode);
|
||||||
* Manage the maximum number of in-progress matches allowed by this query
|
* Manage the maximum number of in-progress matches allowed by this query
|
||||||
* cursor.
|
* cursor.
|
||||||
*
|
*
|
||||||
* Query cursors have a maximum capacity for storing lists of in-progress
|
* Query cursors have an optional maximum capacity for storing lists of
|
||||||
* captures. If this capacity is exceeded, then the earliest-starting match will
|
* in-progress captures. If this capacity is exceeded, then the
|
||||||
* silently be dropped to make room for further matches.
|
* earliest-starting match will silently be dropped to make room for further
|
||||||
*
|
* matches. This maximum capacity is optional — by default, query cursors allow
|
||||||
* By default, this limit is 65,536 pending matches, which is effectively
|
* any number of pending matches, dynamically allocating new space for them as
|
||||||
* unlimited for most queries and syntax trees. You can optionally set this to a
|
* needed as the query is executed.
|
||||||
* lower number if you want to have (and check) a tighter bound on query
|
|
||||||
* complexity.
|
|
||||||
*
|
|
||||||
* If you update the match limit, it must be > 0 and <= 65536.
|
|
||||||
*/
|
*/
|
||||||
bool ts_query_cursor_did_exceed_match_limit(const TSQueryCursor *);
|
bool ts_query_cursor_did_exceed_match_limit(const TSQueryCursor *);
|
||||||
uint32_t ts_query_cursor_match_limit(const TSQueryCursor *);
|
uint32_t ts_query_cursor_match_limit(const TSQueryCursor *);
|
||||||
|
|
|
||||||
|
|
@ -152,10 +152,10 @@ typedef struct {
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
|
uint32_t capture_list_id;
|
||||||
uint16_t start_depth;
|
uint16_t start_depth;
|
||||||
uint16_t step_index;
|
uint16_t step_index;
|
||||||
uint16_t pattern_index;
|
uint16_t pattern_index;
|
||||||
uint16_t capture_list_id;
|
|
||||||
uint16_t consumed_capture_count: 12;
|
uint16_t consumed_capture_count: 12;
|
||||||
bool seeking_immediate_match: 1;
|
bool seeking_immediate_match: 1;
|
||||||
bool has_in_progress_alternatives: 1;
|
bool has_in_progress_alternatives: 1;
|
||||||
|
|
@ -183,7 +183,7 @@ typedef struct {
|
||||||
// use. We reuse those existing-but-unused capture lists before trying to
|
// use. We reuse those existing-but-unused capture lists before trying to
|
||||||
// allocate any new ones. We use an invalid value (UINT32_MAX) for a capture
|
// allocate any new ones. We use an invalid value (UINT32_MAX) for a capture
|
||||||
// list's length to indicate that it's not in use.
|
// list's length to indicate that it's not in use.
|
||||||
uint16_t free_capture_list_count;
|
uint32_t free_capture_list_count;
|
||||||
} CaptureListPool;
|
} CaptureListPool;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -367,9 +367,7 @@ static CaptureListPool capture_list_pool_new(void) {
|
||||||
return (CaptureListPool) {
|
return (CaptureListPool) {
|
||||||
.list = array_new(),
|
.list = array_new(),
|
||||||
.empty_list = array_new(),
|
.empty_list = array_new(),
|
||||||
// The maximum maxmimum is 64K, since we use `uint16_t` as our capture list
|
.max_capture_list_count = UINT32_MAX,
|
||||||
// index type.
|
|
||||||
.max_capture_list_count = 65536,
|
|
||||||
.free_capture_list_count = 0,
|
.free_capture_list_count = 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -2318,7 +2316,7 @@ uint32_t ts_query_cursor_match_limit(const TSQueryCursor *self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ts_query_cursor_set_match_limit(TSQueryCursor *self, uint32_t limit) {
|
void ts_query_cursor_set_match_limit(TSQueryCursor *self, uint32_t limit) {
|
||||||
assert(limit > 0 && limit <= 65536);
|
assert(limit > 0);
|
||||||
self->capture_list_pool.max_capture_list_count = limit;
|
self->capture_list_pool.max_capture_list_count = limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue