summaryrefslogtreecommitdiff
path: root/cli/tools/test.rs
diff options
context:
space:
mode:
authorYiyu Lin <linyiyu1992@gmail.com>2023-04-13 09:08:01 +0800
committerGitHub <noreply@github.com>2023-04-13 03:08:01 +0200
commitd790ea7d533c3c48b09a2f16f3fef549aa96be78 (patch)
treeb31fc35baf1f634054f52e94626f0399d187b99b /cli/tools/test.rs
parent19c3e4f6dc31fd78e2793d0596d6a9cc3a30580a (diff)
refactor(cli,ext,ops): cleanup `regex` with `lazy-regex` (#17296)
- bump deps: the newest `lazy-regex` need newer `oncecell` and `regex` - reduce `unwrap` - remove dep `lazy_static` - make more regex cached --------- Co-authored-by: Bartek IwaƄczuk <biwanczuk@gmail.com>
Diffstat (limited to 'cli/tools/test.rs')
-rw-r--r--cli/tools/test.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/cli/tools/test.rs b/cli/tools/test.rs
index ce99a6edc..7d6a6baa4 100644
--- a/cli/tools/test.rs
+++ b/cli/tools/test.rs
@@ -1031,8 +1031,8 @@ fn extract_files_from_source_comments(
scope_analysis: false,
})?;
let comments = parsed_source.comments().get_vec();
- let blocks_regex = Regex::new(r"```([^\r\n]*)\r?\n([\S\s]*?)```")?;
- let lines_regex = Regex::new(r"(?:\* ?)(?:\# ?)?(.*)")?;
+ let blocks_regex = lazy_regex::regex!(r"```([^\r\n]*)\r?\n([\S\s]*?)```");
+ let lines_regex = lazy_regex::regex!(r"(?:\* ?)(?:\# ?)?(.*)");
let files = comments
.iter()
@@ -1049,8 +1049,8 @@ fn extract_files_from_source_comments(
&comment.text,
media_type,
parsed_source.text_info().line_index(comment.start()),
- &blocks_regex,
- &lines_regex,
+ blocks_regex,
+ lines_regex,
)
})
.flatten()
@@ -1069,16 +1069,16 @@ fn extract_files_from_fenced_blocks(
// check can be done to see if a block is inside a comment (and skip typechecking)
// or not by checking for the presence of capturing groups in the matches.
let blocks_regex =
- Regex::new(r"(?s)<!--.*?-->|```([^\r\n]*)\r?\n([\S\s]*?)```")?;
- let lines_regex = Regex::new(r"(?:\# ?)?(.*)")?;
+ lazy_regex::regex!(r"(?s)<!--.*?-->|```([^\r\n]*)\r?\n([\S\s]*?)```");
+ let lines_regex = lazy_regex::regex!(r"(?:\# ?)?(.*)");
extract_files_from_regex_blocks(
specifier,
source,
media_type,
/* file line index */ 0,
- &blocks_regex,
- &lines_regex,
+ blocks_regex,
+ lines_regex,
)
}