[jsword-devel] Code optimisation request

Martin Denham mjdenham at gmail.com
Sat Jun 26 02:22:49 MST 2010


Hi,

I am not sure if I can make code changes in the JSword-common but I haven't
made any before so I thought I would request the change.

In Zip.java, in the uncompress method, could you change:
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        BufferedOutputStream out = new BufferedOutputStream(bos,
expectedLength);
        InflaterInputStream in = new InflaterInputStream(input, new
Inflater(), expectedLength);
        byte[] buf = new byte[expectedLength];
To:
        ByteArrayOutputStream out = new
ByteArrayOutputStream(expectedLength);
        InflaterInputStream in = new InflaterInputStream(input, new
Inflater(), expectedLength);
        byte[] buf = new byte[expectedLength];

There are 2 optimisations:

   1. ByteArrrayOutputStream is passed the expectedLength parameter
   2. BufferedOutputStream is not used because there is no benefit to
   buffering byte array streams.

These changes may seem trivial but I am attempting to use JSword on an
Android mobile and the above prevents many OutOfMemory errors.

Many thanks
Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.crosswire.org/pipermail/jsword-devel/attachments/20100626/a06bded1/attachment.html>


More information about the jsword-devel mailing list