Class FastCursorRandomAccessLoops

java.lang.Object
net.imglib2.loops.FastCursorRandomAccessLoops

final class FastCursorRandomAccessLoops extends Object
This class aims to avoid performance problems of the Java just in time compilation when running a loop that executes an action on a Cursor and multiple RandomAccesses. Such a loop might look like this:


while(--n >= 0) {
  A a = cursorA.next();
  randomAccessB.setPosition( cursorA );
  randomAccessC.setPosition( cursorA );
  action.accept( a, randomAccessB.get(), randomAccessC.get() );
}

Usually such a loop has significant performance problems when used together multiple different classes that implement Cursor, RandomAccess, and action interfaces. This is caused by the JIT-compiler who simple performs badly in these situations. This class solves these performance problems by holding multiple copies of the bytecode of these loops. A bytecode copy can be individually optimized by the Java JIT compiler to perform optimally for a specific use case.