New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Limit trivia by AST MainNode name. #992
Conversation
So I've completed the exercise out of curiosity sake and it turns out this is not good for the performance:
I was actually expecting that let private findTriviaMainNodeFromNameAndRange nodes ((mainNodesNames, range): string list * range) =
nodes
|> List.tryFind(fun n ->
match n.Type with
| MainNode(mn) ->
List.contains mn mainNodesNames && RangeHelpers.rangeEq n.Range range
| _ -> false) would have sped things up. |
Splitting up the trivia main nodes by types upfront improves the situation yet nothing all that significant: let triviaByNodes =
trivia
|> List.choose (fun tn ->
match tn.Type with
| MainNode(mn) -> Some (mn, tn)
| _ -> None)
|> List.groupBy fst
|> List.map (fun (k, g) -> k, List.map snd g)
|> Map.ofList
|
sepNlnConsideringTriviaContentBefore
sepNlnConsideringTriviaContentBefore usages.
Slowly getting there:
The more calls that can be replaced by specific main node or token calls the better it the numbers are. |
Booya 🥰
|
I like the general idea. 👍 I think that with increased use of |
Good idea, that would speed things up. We could do the same thing for the by Token Map in Context as well.
One thing I haven't mentioned here is that although the current tests pass, I did not take every possible scenario into account. |
Hey @jindraivanek, in this PR I've experimented with limiting the allowed match for TriviaNode by the AST MainNode name.
I'd like to hear your opinion on this one.
So the problem was that when printing the trivia of the
TypeDefnSig
it also prints the trivia for theSynTypeDefnSimpleRepr.Union
because they have exactly the range.That is why as a test I further limited the allowed TriviaNodes by type name.
Potentially it can:
This could be beneficial for the benchmark.
If you think this has some value I can flesh out this PR a bit more.
Please let me know what you think.
Many thanks.