Skip to content
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

fix: do not wrap reference-style doc links #5096

Merged
merged 1 commit into from
Nov 23, 2021

Conversation

domodwyer
Copy link
Contributor

@domodwyer domodwyer commented Nov 19, 2021

Changes the behaviour of wrap_comments to ignore reference link lines.

I've put this Regex behind a lazy_static to avoid compiling it each time has_url is run (every comment line?) which is relatively slow:

  • Initialising the Regex where it is used:

    test has_url ... bench:      33,346 ns/iter (+/- 17,023)
    
  • Using a global with lazy_static:

    test has_url ... bench:         141 ns/iter (+/- 2)
    

There's a few more places this optimisation can be applied - I'd be happy to open a follow-up PR to change them all if you're happy with the approach 👍

Fixes #5095, #4933.


  • fix: do not wrap reference-style doc links (d85fd07)

    Prevents wrap_comments from incorrectly wrapping reference-style doc links.
    

Prevents wrap_comments from incorrectly wrapping reference-style doc
links.
@ytmimi
Copy link
Contributor

ytmimi commented Nov 20, 2021

Thanks for the PR!

I like the approach of using lazy_static!, and appreciate you include the benchmark to show why we should be using it. The proposed changes here look good to me!

I'm also all for you opening up another PR if you think the optimization will help. More contributions are always welcome!

@ytmimi
Copy link
Contributor

ytmimi commented Nov 20, 2021

Looks like this might also fix #4933. At the very least they seem related.

@domodwyer
Copy link
Contributor Author

Yep you're right, #5095 is a dupe of #4933 so this PR will fix both - I had a search for existing tickets but didn't see this one!

@ytmimi
Copy link
Contributor

ytmimi commented Nov 20, 2021

I had a search for existing tickets but didn't see this one!

No worries, it's definitely not easy to always find all existing issues. Just a nice coincidence that I was going through the PR backlog after taking a look at your PR and noticed that these two were related.

Copy link
Member

@calebcartwright calebcartwright left a comment

Choose a reason for hiding this comment

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

Nice, thanks @domodwyer and thanks @ytmimi for reviewing! Code changes lgtm, and I think this is a reasonable exclusion to incorporate into the wrapping logic

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.

bug: wrap_comments mangles reference-style links
3 participants