lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r881378 - /lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/DistanceUtils.java
Date Tue, 17 Nov 2009 17:05:40 GMT
Author: yonik
Date: Tue Nov 17 17:05:40 2009
New Revision: 881378

URL: http://svn.apache.org/viewvc?rev=881378&view=rev
Log:
minor optimization, replace /2 with *.5 - multiplication is an order of magnitude faster than
division

Modified:
    lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/DistanceUtils.java

Modified: lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/DistanceUtils.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/DistanceUtils.java?rev=881378&r1=881377&r2=881378&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/DistanceUtils.java
(original)
+++ lucene/solr/trunk/src/java/org/apache/solr/search/function/distance/DistanceUtils.java
Tue Nov 17 17:05:40 2009
@@ -37,8 +37,8 @@
     if ((x1 != x2) || (y1 != y2)) {
       double diffX = x1 - x2;
       double diffY = y1 - y2;
-      double hsinX = Math.sin(diffX / 2);
-      double hsinY = Math.sin(diffY / 2);
+      double hsinX = Math.sin(diffX * 0.5);
+      double hsinY = Math.sin(diffY * 0.5);
       double h = hsinX * hsinX +
               (Math.cos(x1) * Math.cos(x2) * hsinY * hsinY);
       result = (radius * 2 * Math.atan2(Math.sqrt(h), Math.sqrt(1 - h)));



Mime
View raw message