Skip to content

Commit 0efbb7f

Browse files
committed
chore: replace regex with regex-lite, where appropriate
1 parent 0f3cc8f commit 0efbb7f

File tree

8 files changed

+21
-15
lines changed

8 files changed

+21
-15
lines changed

codex-rs/Cargo.lock

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codex-rs/apply-patch/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ workspace = true
1212

1313
[dependencies]
1414
anyhow = "1"
15-
regex = "1.11.1"
1615
serde_json = "1.0.110"
1716
similar = "2.7.0"
1817
thiserror = "2.0.12"

codex-rs/execpolicy/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ env_logger = "0.11.5"
2424
log = "0.4"
2525
multimap = "0.10.0"
2626
path-absolutize = "3.1.1"
27-
regex = "1.11.1"
27+
# Switched from the heavy `regex` crate to the lighter `regex-lite` for our
28+
# simple matching needs.
29+
regex-lite = "0.1"
2830
serde = { version = "1.0.194", features = ["derive"] }
2931
serde_json = "1.0.110"
3032
serde_with = { version = "3", features = ["macros"] }

codex-rs/execpolicy/src/policy.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use multimap::MultiMap;
2-
use regex::Error as RegexError;
3-
use regex::Regex;
2+
use regex_lite::Error as RegexError;
3+
use regex_lite::Regex;
44

55
use crate::ExecCall;
66
use crate::Forbidden;
@@ -29,7 +29,7 @@ impl Policy {
2929
} else {
3030
let escaped_substrings = forbidden_substrings
3131
.iter()
32-
.map(|s| regex::escape(s))
32+
.map(|s| regex_lite::escape(s))
3333
.collect::<Vec<_>>()
3434
.join("|");
3535
Some(Regex::new(&format!("({escaped_substrings})"))?)

codex-rs/execpolicy/src/policy_parser.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::arg_matcher::ArgMatcher;
77
use crate::opt::OptMeta;
88
use log::info;
99
use multimap::MultiMap;
10-
use regex::Regex;
10+
use regex_lite::Regex;
1111
use starlark::any::ProvidesStaticType;
1212
use starlark::environment::GlobalsBuilder;
1313
use starlark::environment::LibraryExtension;
@@ -73,7 +73,7 @@ impl PolicyParser {
7373

7474
#[derive(Debug)]
7575
pub struct ForbiddenProgramRegex {
76-
pub regex: regex::Regex,
76+
pub regex: regex_lite::Regex,
7777
pub reason: String,
7878
}
7979

@@ -93,7 +93,7 @@ impl PolicyBuilder {
9393
}
9494
}
9595

96-
fn build(self) -> Result<Policy, regex::Error> {
96+
fn build(self) -> Result<Policy, regex_lite::Error> {
9797
let programs = self.programs.into_inner();
9898
let forbidden_program_regexes = self.forbidden_program_regexes.into_inner();
9999
let forbidden_substrings = self.forbidden_substrings.into_inner();
@@ -207,7 +207,7 @@ fn policy_builtins(builder: &mut GlobalsBuilder) {
207207
.unwrap()
208208
.downcast_ref::<PolicyBuilder>()
209209
.unwrap();
210-
let compiled_regex = regex::Regex::new(&regex)?;
210+
let compiled_regex = regex_lite::Regex::new(&regex)?;
211211
policy_builder.add_forbidden_program_regex(compiled_regex, reason);
212212
Ok(NoneType)
213213
}

codex-rs/tui/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ratatui = { version = "0.29.0", features = [
3333
"unstable-rendered-line-info",
3434
] }
3535
ratatui-image = "8.0.0"
36-
regex = "1"
36+
regex-lite = "0.1"
3737
serde_json = "1"
3838
shlex = "1.3.0"
3939
strum = "0.27.1"

codex-rs/tui/src/citation_regex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![allow(clippy::expect_used)]
22

3-
use regex::Regex;
3+
use regex_lite::Regex;
44

55
// This is defined in its own file so we can limit the scope of
66
// `allow(clippy::expect_used)` because we cannot scope it to the `lazy_static!`

codex-rs/tui/src/markdown.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ fn rewrite_file_citations<'a>(
7171
None => return Cow::Borrowed(src),
7272
};
7373

74-
CITATION_REGEX.replace_all(src, |caps: &regex::Captures<'_>| {
74+
CITATION_REGEX.replace_all(src, |caps: &regex_lite::Captures<'_>| {
7575
let file = &caps[1];
7676
let start_line = &caps[2];
7777

0 commit comments

Comments
 (0)