Makes sense.

The handler for Point objects can't be removed from the getPoints(Geometry,
List) method, since it's needed for correctness.  But a better
short-circuit can be added to getPoints(Geometry) as you suggest.

I'll make the change soon.

On Wed, Dec 10, 2014 at 2:48 AM, Axel Berndt <[email protected]> wrote:

> Hi,
>
> We just found a not so efficient implementation inside the JTS lib. We are
> using the DistanceOp.nearestPoint(Geometry, Geometry) utility for Point
> geometry objects. This call goes via PointExtractor. getPoints(Geometry
> geom) which forwards to PointExtractor. getPoints(Geometry geom, List list)
> using a new ArrayList(). In JDK 7 they changed the implemenation of the
> default constructor of ArrayList to suppress the initialization of the
> internal array until the first element is added. Only if you add the first
> item the ArrayList with initialize the internal array to the default size
> of 10. This includes some calls like array copying and so on, please see
> the attached screenshot showing a Missing Control allocation graph.
>
> I think the shortcut in PointExtractor. getPoints(Geometry geom, List
> list) was intended to handle Points more efficient.
>   public static List getPoints(Geometry geom, List list)
>   {
>       if (geom instanceof Point) {
>           list.add(geom);
>       }
>     ...
>
> The change in the JDK unfortunately introduces some new costs to it.
> The impelemation could be improved by moving the shortcut to the
> getPoints(Geometry) method like this:
>   public static List getPoints(Geometry geom)
>   {
>       if (geom instanceof Point) {
>           return Collections.singletonList(geom);
>       }
>     return getPoints(geom, new ArrayList());
>   }
>
> Best regards,
>
> Axel
>
>
>
> ------------------------------------------------------------------------------
> 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=164703151&iu=/4140/ostg.clktrk
> _______________________________________________
> Jts-topo-suite-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user
>
>
------------------------------------------------------------------------------
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=164703151&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