Skip to content

Commit

Permalink
Use lazy_static! for Regex allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
raphjaph authored and arik-so committed Feb 24, 2025
1 parent 39114e7 commit 73f4d07
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ struct Search {
#[folder = "static"]
struct StaticAssets;

lazy_static! {
static ref REGEX_SAT_AT_INDEX: Regex = Regex::new(r"(?m)r\/sat\/\d+\/at\/-?\d+$").unwrap();
}

#[derive(Debug, Parser, Clone)]
pub struct Server {
#[arg(
Expand Down Expand Up @@ -548,8 +552,7 @@ impl Server {

// This is a workaround for the fact the the /r/sat/<SAT_NUMBER>/at/<INDEX>
// does not return a 404 when no inscription is present on the sat.
let regex = Regex::new(r"(?m)r\/sat\/\d+\/at\/-?\d+$").unwrap();
if regex.is_match(&path) {
if REGEX_SAT_AT_INDEX.is_match(&path) {
let (parts, body) = response.into_parts();

let bytes = axum::body::to_bytes(body, usize::MAX)
Expand Down

0 comments on commit 73f4d07

Please sign in to comment.