Hi,

I've noticed in the newer versions of JTS that Geometry.equals(Object)
calls into Geometry.equalsExact(other) which then goes into the subclasses
to determine equality based on a tolerance.  It appears that all identity
checking has been removed from equals(Object) but you could speed up the
check with a simple check for reference equality.  Specifically, a one line
change to Geometry.equalsExact(other) like this:

public boolean equalsExact(Geometry other) {
        return this == other || equalsExact(other, 0);
    }

will return quicker and save you the trouble of calculating equalsExact
with the tolerance if you are comparing the exact same object in memory.

This has performance implications beyonds just equals() calls.  I traced
this down while investigating Geotools'
PolygonHandler.assignHolesToShells() because the
ArrayList.indexOf(LinearRing) was slow and would compare the equalsExact
even when it had the exact same object.  This slight enhancement only saves
time when you do encounter the exact same reference, but in those cases it
can save a measurable amount of time.

Please consider this slight optimization for a future release of JTS.
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Jts-topo-suite-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user

Reply via email to