Skip to content

Commit

Permalink
(BIN) skip build REGEX_DUR_OFFSET if passed empty String
Browse files Browse the repository at this point in the history
  • Loading branch information
jtmoon79 committed Jun 9, 2024
1 parent 57d7005 commit 11d17c6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/bin/s4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,12 @@ fn offset_match_to_offset_addsub(offset_str: &str) -> DUR_OFFSET_ADDSUB {
fn string_wdhms_to_duration(val: &String) -> Option<(Duration, DUR_OFFSET_TYPE)> {
defn!("({:?})", val);

if val.is_empty() {
// take the early exit to avoid building regex `REGEX_DUR_OFFSET` (expensive operation)
defx!("is_empty; return None");
return None;
}

let mut duration_offset_type: DUR_OFFSET_TYPE = DUR_OFFSET_TYPE::Now;
let mut duration_addsub: DUR_OFFSET_ADDSUB = DUR_OFFSET_ADDSUB::Add;
let mut seconds: i64 = 0;
Expand Down

0 comments on commit 11d17c6

Please sign in to comment.