Index: src/Common/NetTopologySuite/Operation/Predicate/SegmentIntersectionTester.cs
===================================================================
diff -u -r8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9 -r5fc71a385897af92ccb092f2f969b5709afab85a
--- src/Common/NetTopologySuite/Operation/Predicate/SegmentIntersectionTester.cs (.../SegmentIntersectionTester.cs) (revision 8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9)
+++ src/Common/NetTopologySuite/Operation/Predicate/SegmentIntersectionTester.cs (.../SegmentIntersectionTester.cs) (revision 5fc71a385897af92ccb092f2f969b5709afab85a)
@@ -10,21 +10,21 @@
/// Optimized for small geometry size.
/// Short-circuited to return as soon an intersection is found.
///
- public class SegmentIntersectionTester
+ public class SegmentIntersectionTester
{
// for purposes of intersection testing, don't need to set precision model
- private LineIntersector li = new RobustLineIntersector();
+ private readonly LineIntersector li = new RobustLineIntersector();
private bool hasIntersection = false;
- private ICoordinate pt00 = new Coordinate();
- private ICoordinate pt01 = new Coordinate();
- private ICoordinate pt10 = new Coordinate();
- private ICoordinate pt11 = new Coordinate();
+ private readonly ICoordinate pt00 = new Coordinate();
+ private readonly ICoordinate pt01 = new Coordinate();
+ private readonly ICoordinate pt10 = new Coordinate();
+ private readonly ICoordinate pt11 = new Coordinate();
///
///
///
- public SegmentIntersectionTester() { }
+ public SegmentIntersectionTester() {}
///
///
@@ -34,12 +34,14 @@
///
public bool HasIntersectionWithLineStrings(ICoordinateSequence seq, IList lines)
{
- for (IEnumerator i = lines.GetEnumerator(); i.MoveNext(); )
+ for (IEnumerator i = lines.GetEnumerator(); i.MoveNext();)
{
ILineString line = (ILineString) i.Current;
HasIntersection(seq, line.CoordinateSequence);
if (hasIntersection)
+ {
break;
+ }
}
return hasIntersection;
}
@@ -50,22 +52,24 @@
///
///
///
- public bool HasIntersection(ICoordinateSequence seq0, ICoordinateSequence seq1)
+ public bool HasIntersection(ICoordinateSequence seq0, ICoordinateSequence seq1)
{
- for (int i = 1; i < seq0.Count && ! hasIntersection; i++)
+ for (int i = 1; i < seq0.Count && !hasIntersection; i++)
{
seq0.GetCoordinate(i - 1, pt00);
seq0.GetCoordinate(i, pt01);
- for (int j = 1; j < seq1.Count && ! hasIntersection; j++)
+ for (int j = 1; j < seq1.Count && !hasIntersection; j++)
{
seq1.GetCoordinate(j - 1, pt10);
seq1.GetCoordinate(j, pt11);
li.ComputeIntersection(pt00, pt01, pt10, pt11);
if (li.HasIntersection)
+ {
hasIntersection = true;
+ }
}
}
return hasIntersection;
}
}
-}
+}
\ No newline at end of file