Skip to content

Conversation

@mamaniv
Copy link

@mamaniv mamaniv commented Aug 9, 2021

This commit solves an issue described in #562
It also contains a change in the relevant test.

@davidbonnet
Copy link
Owner

Thanks @mamaniv for suggesting this change. It's going in the right direction, however I'm afraid that the performance impact of filter calls with inline functions will be huge. An alternative that doesn't define inline functions (without going through the entire comments list every time) should be faster.

const statement = statements[i]
if (writeComments && statement.comments != null) {
formatComments(state, statement.comments, indent, lineEnd)
formatComments(state, statement.comments.filter(comment => comment.end < statement.start), indent, lineEnd)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, instead of filtering comments every time, it'd be more efficient to apply the logic in the filter predicate inside the formatComments function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants