Skip to content

Commit

Permalink
Merge #669
Browse files Browse the repository at this point in the history
669: Clippy: Simplify Duplicated code block. r=lnicola a=martinfrances107

- [x ] I agree to follow the project's [code of conduct](https://github.com/georust/geo/blob/master/CODE_OF_CONDUCT.md).
---

Just clearing 2 clippy lint warnings. 

A) This conditional 

```
-        if left == 0 {
-            obtuse = true;
-        }

```

is considered duplicate code 

B) the remaining if statement can be simplified.


Co-authored-by: Martin <martinfrances107@hotmail.com>
  • Loading branch information
bors[bot] and martinfrances107 committed Oct 14, 2021
2 parents f43af7a + 7680c90 commit f699570
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions geo/src/algorithm/polygon_distance_fast_path.rs
Expand Up @@ -369,29 +369,25 @@ where
let perpunit = unitpvector(p, punit);
let mut obtuse = false;
let left = leftturn(p, perpunit, Point(pnext));
if left == 0 {
obtuse = true;
}
if clockwise {
if left == 0 {
obtuse = true;
}
if left == -1 {
angle = T::PI() / (T::one() + T::one());
} else if !obtuse {
angle = (-sine).asin();
} else {
angle = T::PI() - (-sine).asin();
}
} else if left == -1 {
angle = T::PI() / (T::one() + T::one());
} else if !obtuse {
angle = sine.asin();
} else {
if left == 0 {
obtuse = true;
}
if left == -1 {
angle = T::PI() / (T::one() + T::one());
} else if !obtuse {
angle = sine.asin();
} else {
angle = T::PI() - sine.asin();
}
angle = T::PI() - sine.asin();
}

angle
}

Expand Down

0 comments on commit f699570

Please sign in to comment.