Skip to content

Commit

Permalink
Merge pull request #52 from lynn/fix_underflow
Browse files Browse the repository at this point in the history
Fix underflow when MIN_BINARY_OP_LEN > 1
  • Loading branch information
JayXon authored Jul 5, 2024
2 parents 6490659 + fbf2914 commit 2088dbb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ fn find_expressions_multithread(
let cache = &mut_cache;
let hashset_cache = &mut_hashset_cache;

let mut cn = (1..n - MIN_BINARY_OP_LEN)
let mut cn = (1..n.saturating_sub(MIN_BINARY_OP_LEN))
.into_par_iter()
.flat_map(|k| {
cache[k].par_iter().map(move |r| {
Expand Down Expand Up @@ -395,7 +395,7 @@ fn find_expressions(cache: &mut Cache, hashset_cache: &mut HashSetCache, n: usiz
find_variables_and_literals(&mut cn, n);
find_parens_expressions(&mut cn, cache, hashset_cache, n);
find_unary_expressions(&mut cn, cache, hashset_cache, n);
for k in 1..n - MIN_BINARY_OP_LEN {
for k in 1..n.saturating_sub(MIN_BINARY_OP_LEN) {
for r in &cache[k] {
find_binary_expressions_left(&mut cn, cache, hashset_cache, n, k, r);
}
Expand Down

0 comments on commit 2088dbb

Please sign in to comment.