summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlyia Kaushansky <ikaushan@google.com>2011-11-08 11:06:06 -0500
committerMichael Bolin <bolinfest@google.com>2011-11-08 11:06:06 -0500
commita497b8273a8eaa0caffa9b13a1da4aa483a8b718 (patch)
treedb1a50f5ee65eb09beadac1e3a7bec7504efd0ae
parent03d6087312c92f1fbdafcae0c0a7596d270cee0a (diff)
downloads2-geometry-library-java-a497b8273a8eaa0caffa9b13a1da4aa483a8b718.tar.gz
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
-rw-r--r--src/com/google/common/geometry/S2.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/com/google/common/geometry/S2.java b/src/com/google/common/geometry/S2.java
index 1b49ca9..dbbeeff 100644
--- a/src/com/google/common/geometry/S2.java
+++ b/src/com/google/common/geometry/S2.java
@@ -521,6 +521,9 @@ public final strictfp class S2 {
* a,b,c, except that it has additional logic to make sure that the above
* properties hold even when the three points are coplanar, and to deal with
* the limitations of floating-point arithmetic.
+ *
+ * Note: a, b and c are expected to be of unit length. Otherwise, the results
+ * are undefined.
*/
public static int robustCCW(S2Point a, S2Point b, S2Point c) {
return robustCCW(a, b, c, S2Point.crossProd(a, b));
@@ -529,11 +532,12 @@ public final strictfp class S2 {
/**
* A more efficient version of RobustCCW that allows the precomputed
* cross-product of A and B to be specified.
+ *
+ * Note: a, b and c are expected to be of unit length. Otherwise, the results
+ * are undefined
*/
public static int robustCCW(S2Point a, S2Point b, S2Point c, S2Point aCrossB) {
- Preconditions.checkArgument(isUnitLength(a));
- Preconditions.checkArgument(isUnitLength(b));
- Preconditions.checkArgument(isUnitLength(c));
+ // assert (isUnitLength(a) && isUnitLength(b) && isUnitLength(c));
// There are 14 multiplications and additions to compute the determinant
// below. Since all three points are normalized, it is possible to show