Skip to content

Commit

Permalink
remove rregex dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmgray committed Sep 2, 2023
1 parent e00ffa7 commit 9d54a9c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 59 deletions.
45 changes: 0 additions & 45 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ bit-set = "0.5"
pyo3 = "0.19"
ordered-float = "3.9"
rand = "0.8"
regex = "1.9"
rustc-hash = "1.1"

[profile.release]
Expand Down
24 changes: 11 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use bit_set::BitSet;
use ordered_float::OrderedFloat;
use pyo3::prelude::*;
use rand::Rng;
use regex::Regex;
use rustc_hash::FxHashMap;
use std::collections::{BTreeSet, BinaryHeap};
use std::f32;
Expand Down Expand Up @@ -620,19 +619,18 @@ impl ContractionProcessor {
cost_cap: Option<Score>,
allow_outer: Option<bool>,
) {
// parse the minimize
// parse the minimize argument
let minimize = minimize.unwrap_or("flops".to_string());

let re = Regex::new(r"^(flops|size|write|combo|limit)(?:-(\d+(?:\.\d+)?))?$").unwrap();
let captures = re.captures(minimize.as_str()).unwrap();
let minimize_type = captures.get(1).unwrap().as_str();
let factor = f32::ln(
captures
.get(2)
.map(|m| m.as_str().parse::<f32>().unwrap())
.unwrap_or(64.),
);

let mut minimize_split = minimize.split('-');
let minimize_type = minimize_split.next().unwrap();
let factor = minimize_split
.next()
.map_or(64.0, |s| s.parse::<f32>().unwrap())
.ln();
if minimize_split.next().is_some() {
// multiple hyphens -> raise error
panic!("invalid minimize: {:?}", minimize);
}
let compute_cost = match minimize_type {
"flops" => compute_con_cost_flops,
"size" => compute_con_cost_size,
Expand Down

0 comments on commit 9d54a9c

Please sign in to comment.