-
Improvement
-
Resolution: Done
-
Medium
-
None
SegmentedJournalReader has two modes of operation based on JournalReader.Mode, which is an invariant known at instantiation time. We do not amortize this invariant, leaving each invocation of SegmentedJournalReader.hasNext() checking it all over again.
Since Java is an object-oriented language, we can express this invariant in the class hierarchy by having two implementation classes – one for Mode.ALL and one for Mode.COMMITS. This will not only simplify the code, but also allow the JVM to see what is going on.
While we are in this area, also explore other optimization opportunities.