Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Improve performance of package comment regex #1799
A package comment is not always at the start of the document; it can be preceded with one or more other comment blocks.
For example this file will no longer work correct:
I'm not sure if there is a way to make this significantly faster; maybe using
I played around with a number of regex that mostly handled these cases, but they became uncomfortably complex. Taking a step back, the real performance problems stem from the /* ... */ matching, since they can be started with any
This start of line anchor helps a lot because it prevents quoted
Note that if there are block (/* .. */) comments (like a license) and then a block commented package comment, the license+package get folded together, like you were just mentioning. But that behavior is present even in the released version, and line comment style is more common anyways.
If you like this approach I'll update that PR with it.