Skip to content

Fix inline comments#563

Open
mamaniv wants to merge 2 commits into
davidbonnet:mainfrom
mamaniv:master
Open

Fix inline comments#563
mamaniv wants to merge 2 commits into
davidbonnet:mainfrom
mamaniv:master

Conversation

@mamaniv
Copy link
Copy Markdown

@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
Copy Markdown
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.

Comment thread src/astring.js
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
Copy Markdown
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