LongestCommonSubsequence<T>.EnsureHashCodes2 (src/DiffLib/LongestCommonSubsequence.cs:85-110) has two while loops that lazily extend the hashcode index of collection2 downward/upward:
while (_HashCodes2Lower > lower) { ... }
while (_HashCodes2Upper < upper) { ... }
These are never reached. The very first call comes from LongestCommonSubsectionDiff.Calculate, which always passes the full range [0, collection2.Count). Every recursive Find call afterwards uses sub-ranges, so _HashCodes2Lower is already 0 (never > lower) and _HashCodes2Upper is already Count (never < upper). Coverage confirms lines 99–109 are never executed.
So the "lazy/incremental" design was either intended to be driven differently (build the index only for the sub-range actually needed) or is leftover from an earlier version. Two possible resolutions:
- Remove the dead code and the
_FirstHashCodes2 / _HashCodes2Lower / _HashCodes2Upper bookkeeping, since the index is always built once for the full range — simplifies the class considerably.
- Actually make it lazy (build the index for the requested sub-range on demand) if the original intent was to avoid indexing the whole of collection2 up front for large inputs.
Worth deciding which, because right now it's carrying complexity that does nothing.
LongestCommonSubsequence<T>.EnsureHashCodes2(src/DiffLib/LongestCommonSubsequence.cs:85-110) has twowhileloops that lazily extend the hashcode index of collection2 downward/upward:These are never reached. The very first call comes from
LongestCommonSubsectionDiff.Calculate, which always passes the full range[0, collection2.Count). Every recursiveFindcall afterwards uses sub-ranges, so_HashCodes2Loweris already0(never> lower) and_HashCodes2Upperis alreadyCount(never< upper). Coverage confirms lines 99–109 are never executed.So the "lazy/incremental" design was either intended to be driven differently (build the index only for the sub-range actually needed) or is leftover from an earlier version. Two possible resolutions:
_FirstHashCodes2 / _HashCodes2Lower / _HashCodes2Upperbookkeeping, since the index is always built once for the full range — simplifies the class considerably.Worth deciding which, because right now it's carrying complexity that does nothing.