tree-sitter / tree-sitter-haskell

Haskell grammar for tree-sitter.
MIT License
152 stars 36 forks source link

A few scanner microoptimizations #63

Closed 414owen closed 2 years ago

414owen commented 2 years ago

None of this has had any tangible impact on performance, so either the compiler already knew what to do, or the scanner is no longer the bottleneck.

We might avoid a few potential stackoverflows though.

414owen commented 2 years ago

Woops, test fail with -DDEBUG

tek commented 2 years ago

btw, what's the point of using static for functions?

414owen commented 2 years ago

btw, what's the point of using static for functions?

static functions are only visible within the current compilation unit, so the only functions our file exports are the tree_sitter_haskell* functions. It just lets the compiler do more optimizations, inline things that it otherwise wouldn't have been, do dead code analysis, that sort of thing.

414owen commented 2 years ago

I'd deleted an important line of code -_-

wenkokke commented 2 years ago

@414owen Any chance of getting rid of realloc? (Or conditionally getting rid of it with #ifdef __EMSCRIPTEN__?)

414owen commented 2 years ago

@wenkokke realloc seems pretty important. Let's see if upstream wants to include it: https://github.com/tree-sitter/tree-sitter/pull/1571

(I assume _realloc is the correct way to do this?)

wenkokke commented 2 years ago

@414owen _realloc is correct, yes :)

414owen commented 2 years ago

@tek this is safe to merge