Skip to content

Commit

Permalink
Reduce library size by replacing regex with regex-light (#15)
Browse files Browse the repository at this point in the history
For the use case regex-light should be sufficient
It reduces the binary size by about 1MB
  • Loading branch information
bachp authored Feb 15, 2024
1 parent 82b284a commit d34b07d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion oasgen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ serde_yaml = "0.9.22"
tokio = { version = "1.29.1", features = ["full"] }
swagger-ui2 = { version = "0.6", optional = true, path = "../swagger-ui" }
tower-cookies = { version = "0.10.0", optional = true }
regex = "1.9.1"
regex-lite = "0.1.5"
once_cell = "1.18.0"
http-body = "1.0.0"
http-body-util = "0.1.0"
Expand Down
2 changes: 1 addition & 1 deletion oasgen/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ fn replace_path_params(path: &str) -> String {
return path.to_string();
}
use once_cell::sync::OnceCell;
use regex::Regex;
use regex_lite::Regex;
static REMAP: OnceCell<Regex> = OnceCell::new();
let remap = REMAP.get_or_init(|| Regex::new("/:([a-zA-Z0-9_]+)").unwrap());
remap.replace_all(&path, "/{$1}").to_string()
Expand Down

0 comments on commit d34b07d

Please sign in to comment.