optimized approxEquals in GeoObject.java
To make the code more concise and efficient, we can simplify the conditional expressions and combine multiple conditions into a single return statement using short-circuit evaluation.
Best pull request so far. Appreciate the effort.
LGTM
genius
Impossible; an actual PR?
On this repo?
Groundbreaking. This could be the missing link.
LGTM
LGTM
better-algorithm
Groundbreaking
Feature is a little too big for the scope of this project; perhaps create a fork?
this would be the least lines and most maintainable.
return a!=null&&b!=null&&a.accuracy==b.accuracy&&Math.abs(a.latitude-b.latitude)<=COORDS_EQUALITY_THRESHOLD&&Math.abs(a.longitude-b.longitude)<=COORDS_EQUALITY_THRESHOLD&&a.radius==b.radius&&a.source==b.source;
this would be the least lines and most maintainable.
return a!=null&&b!=null&&a.accuracy==b.accuracy&&Math.abs(a.latitude-b.latitude)<=COORDS_EQUALITY_THRESHOLD&&Math.abs(a.longitude-b.longitude)<=COORDS_EQUALITY_THRESHOLD&&a.radius==b.radius&&a.source==b.source;
I noticed that the Double.compare() method was removed. Can you explain the reason for this? It seems to be a more accurate way to compare two double values.
this would be the least lines and most maintainable.
return a!=null&&b!=null&&a.accuracy==b.accuracy&&Math.abs(a.latitude-b.latitude)<=COORDS_EQUALITY_THRESHOLD&&Math.abs(a.longitude-b.longitude)<=COORDS_EQUALITY_THRESHOLD&&a.radius==b.radius&&a.source==b.source;
I noticed that the
Double.compare()method was removed. Can you explain the reason for this? It seems to be a more accurate way to compare two double values.
I would stick with the compare() method. Double values can have rounding inaccuracies due to their representation in the computer's limited memory space of (usually) 64 bits.
https://www.baeldung.com/java-comparing-doubles
this would be the least lines and most maintainable.
return a!=null&&b!=null&&a.accuracy==b.accuracy&&Math.abs(a.latitude-b.latitude)<=COORDS_EQUALITY_THRESHOLD&&Math.abs(a.longitude-b.longitude)<=COORDS_EQUALITY_THRESHOLD&&a.radius==b.radius&&a.source==b.source;
I noticed that the
Double.compare()method was removed. Can you explain the reason for this? It seems to be a more accurate way to compare two double values.I would stick with the compare() method. Double values can have rounding inaccuracies due to their representation in the computer's limited memory space of (usually) 64 bits.
https://www.baeldung.com/java-comparing-doubles
Exactly!