This method has very simple logic, the reasoning for which is left
unexplained.
Add a comment about what is going on and use assign-and-check construct
to trim a bit of byte code.
JIRA: CONTROLLER-2106
Change-Id: I5d4e5551ae089489636da38600109f7821fa306b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
@Override
public final Indexed<E> getCurrentEntry() {
- Indexed<E> currentEntry = currentReader.getCurrentEntry();
- if (currentEntry != null) {
- return currentEntry;
- }
- return previousEntry;
+ // If previousEntry was the last in the previous segment, we may have moved currentReader to the next segment.
+ // That segment may be empty, though, in which case we need to report the previousEntry.
+ final Indexed<E> currentEntry;
+ return (currentEntry = currentReader.getCurrentEntry()) != null ? currentEntry : previousEntry;
}
@Override