RXTX is a native lib providing serial and parallel communication for the Java Development Toolkit (JDK). All deliverables are under the gnu LGPL license. The native part is developed in C.
If you are using the parallel port functions of this project for version rxtx-2.1-7r2 or older, you may be interested in this code optimization, it is a small change but it may improve the resource usage in certain cases.
Let’s take a look to readArray function in ParallelImp.c, this is a summary of the current implementation:
In C we can increment the output buffer pointer to the position we want to start to write (offset) directly, avoiding the necessity of allocating a new buffer and copying the contents, for example:
This kind of optimization can be also applied to the writeArray function in the same source file.
I’m going to send this information to the RXTX project mailing list, hopefully it will be available in next version!