Skip to content

Commit

Permalink
Auto merge of rust-lang#84034 - jyn514:regex-in-loop, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
Fix perf regression in rustdoc::bare_urls

This regressed in rust-lang#81764. After that PR, rustdoc compiled the regex for every single item in the crate: https://perf.rust-lang.org/compare.html?start=125505306744a0a5bb01d62337260a95d9ff8d57&end=2e495d2e845cf27740e3665f718acfd3aa17253e&stat=instructions%3Au

This would have been caught by `clippy::declare_interior_mutable_const` (cc rust-lang#77983).
  • Loading branch information
bors committed Apr 9, 2021
2 parents da0b9b6 + 8c7b7dd commit 8513e78
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/librustdoc/passes/bare_urls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ crate const CHECK_BARE_URLS: Pass = Pass {
description: "detects URLs that are not hyperlinks",
};

const URL_REGEX: SyncLazy<Regex> = SyncLazy::new(|| {
static URL_REGEX: SyncLazy<Regex> = SyncLazy::new(|| {
Regex::new(concat!(
r"https?://", // url scheme
r"([-a-zA-Z0-9@:%._\+~#=]{2,256}\.)+", // one or more subdomains
Expand Down

0 comments on commit 8513e78

Please sign in to comment.