Skip to content

Commit a497b82

Browse files
Ilyia KaushanskyMichael Bolin
authored andcommitted
Removing very slow precondition checks. Removing these yields 10%
speedup of S2Polygon.isValid(). This particular hot spot was identified using YourKit profiler. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=25256987
1 parent 03d6087 commit a497b82

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

  • src/com/google/common/geometry

src/com/google/common/geometry/S2.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,9 @@ public static boolean simpleCCW(S2Point a, S2Point b, S2Point c) {
521521
* a,b,c, except that it has additional logic to make sure that the above
522522
* properties hold even when the three points are coplanar, and to deal with
523523
* the limitations of floating-point arithmetic.
524+
*
525+
* Note: a, b and c are expected to be of unit length. Otherwise, the results
526+
* are undefined.
524527
*/
525528
public static int robustCCW(S2Point a, S2Point b, S2Point c) {
526529
return robustCCW(a, b, c, S2Point.crossProd(a, b));
@@ -529,11 +532,12 @@ public static int robustCCW(S2Point a, S2Point b, S2Point c) {
529532
/**
530533
* A more efficient version of RobustCCW that allows the precomputed
531534
* cross-product of A and B to be specified.
535+
*
536+
* Note: a, b and c are expected to be of unit length. Otherwise, the results
537+
* are undefined
532538
*/
533539
public static int robustCCW(S2Point a, S2Point b, S2Point c, S2Point aCrossB) {
534-
Preconditions.checkArgument(isUnitLength(a));
535-
Preconditions.checkArgument(isUnitLength(b));
536-
Preconditions.checkArgument(isUnitLength(c));
540+
// assert (isUnitLength(a) && isUnitLength(b) && isUnitLength(c));
537541

538542
// There are 14 multiplications and additions to compute the determinant
539543
// below. Since all three points are normalized, it is possible to show

0 commit comments

Comments
 (0)