Simplify testing-only ts_stack_iterate function

This commit is contained in:
Max Brunsfeld 2018-03-29 17:50:07 -07:00
parent 5520983144
commit dbe77e7199
3 changed files with 44 additions and 41 deletions

View file

@ -54,13 +54,12 @@ vector<StackEntry> get_stack_entries(Stack *stack, StackVersion version) {
ts_stack_iterate(
stack,
version,
[](void *payload, TSStateId state, const TreeArray *trees, uint32_t tree_count) -> StackIterateAction {
[](void *payload, TSStateId state, uint32_t tree_count) {
auto entries = static_cast<vector<StackEntry> *>(payload);
StackEntry entry = {state, tree_count};
if (find(entries->begin(), entries->end(), entry) == entries->end()) {
entries->push_back(entry);
}
return StackIterateNone;
}, &result);
return result;
}