7

fix: do not wrap reference-style doc links by domodwyer · Pull Request #5096 · r...

 2 years ago
source link: https://github.com/rust-lang/rustfmt/pull/5096
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Copy link

Contributor

domodwyer commented 22 days ago

edited

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 +1

Fixes #5095, #4933.


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

    Prevents wrap_comments from incorrectly wrapping reference-style doc links.
    

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK