Fix perf regression in non-autolinks

Before, this was compiling the regex on every single item in the crate.

This would have been caught by `clippy::declare_interior_mutable_const`.
This commit is contained in:
Joshua Nelson 2021-04-09 09:58:40 -04:00
parent bc66b92f7f
commit 8c7b7dd041

View file

@ -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