mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 21:48:35 +00:00
fix(treesitter): make tests for memoize more robust
Instead of painfully messing with timing to determine if queries were reparsed, we can simply keep a counter next to the call to ts_query_new Also memoization had a hidden dependency on the garbage collection of the the key, a hash value which never is kept around in memory. this was done intentionally as the hash does not capture all relevant state for the query (external included files) even if actual query objects still would be reachable in memory. To make the test fully deterministic in CI, we explicitly control GC.
This commit is contained in:
@@ -1318,6 +1318,7 @@ int tslua_parse_query(lua_State *L)
|
||||
size_t len;
|
||||
const char *src = lua_tolstring(L, 2, &len);
|
||||
|
||||
tslua_query_parse_count++;
|
||||
uint32_t error_offset;
|
||||
TSQueryError error_type;
|
||||
TSQuery *query = ts_query_new(lang, src, (uint32_t)len, &error_offset, &error_type);
|
||||
|
@@ -1,7 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <lua.h> // IWYU pragma: keep
|
||||
#include <stdint.h>
|
||||
|
||||
#include "nvim/macros_defs.h"
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "lua/treesitter.h.generated.h"
|
||||
#endif
|
||||
|
||||
EXTERN uint64_t tslua_query_parse_count INIT( = 0);
|
||||
|
Reference in New Issue
Block a user