[OpenJDK 2D-Dev] [OpenJDK Rasterizer] Path2d needRoom very slow for huge paths

Laurent Bourgès bourges.laurent at gmail.com
Fri Apr 10 15:07:52 UTC 2015


Jim,

Here is the new webrev:
http://cr.openjdk.java.net/~lbourges/path2D/Path2D_needRoom.1/

Changes:
- needRoom() applies your pseudo-code; see expandPointTypes() and
expandCoords()
- added a new public trimToSize() method to Path2D implemented by both
Path2D.Float and Path2D.Double classes

Cheers,
Laurent

2015-04-08 22:53 GMT+02:00 Jim Graham <james.graham at oracle.com>:

> Hi Laurent,
>
> I'd probably do:
>
> int newsizemin = oldcount + newitems;
> if (newsizemin < oldcount) {
>     // hard overflow failure - we can't even accommodate
>     // new items without overflowing
>     return failure, throw exception?
> }
> int newsize = <growth algorithm computation>;
> if (newsize < newsizemin) {
>     // overflow in growth algorithm computation
>     newsize = newsizemin;
>     ... OR ...
>     newsize = MAX_INT;
> }
> while (true) {
>     try {
>         allocate newsize;
>         break;  (or return?)
>     } catch (OOME e) {
>         if (newsize == newsizemin) {
>             throw e;
>         }
>     }
>     newsize = newsizemin + (newsize - newsizemin) / 2;
> }
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/2d-dev/attachments/20150410/f4190735/attachment.html>


More information about the 2d-dev mailing list