@Nullable public static <T> Change buildChanges(@NotNull T[] objects1, @NotNull T[] objects2) throws FilesTooBigForDiffException { // Old variant of enumerator worked incorrectly with null values. // This check is to ensure that the corrected version does not introduce bugs. for (T anObjects1 : objects1) LOG.assertTrue(anObjects1 != null); for (T anObjects2 : objects2) LOG.assertTrue(anObjects2 != null); final int startShift = getStartShift(objects1, objects2); final int endCut = getEndCut(objects1, objects2, startShift); Enumerator<T> enumerator = new Enumerator<T>(objects1.length + objects2.length, ContainerUtil.<T>canonicalStrategy()); int[] ints1 = enumerator.enumerate(objects1, startShift, endCut); int[] ints2 = enumerator.enumerate(objects2, startShift, endCut); Reindexer reindexer = new Reindexer(); int[][] discarded = reindexer.discardUnique(ints1, ints2); IntLCS intLCS = new IntLCS(discarded[0], discarded[1]); intLCS.execute(); ChangeBuilder builder = new ChangeBuilder(startShift); reindexer.reindex(intLCS.getPaths(), builder); return builder.getFirstChange(); }
@Nullable public static <T> Change buildChanges(@Nonnull T[] objects1, @Nonnull T[] objects2) throws FilesTooBigForDiffException { // Old variant of enumerator worked incorrectly with null values. // This check is to ensure that the corrected version does not introduce bugs. for (T anObjects1 : objects1) LOG.assertTrue(anObjects1 != null); for (T anObjects2 : objects2) LOG.assertTrue(anObjects2 != null); final int startShift = getStartShift(objects1, objects2); final int endCut = getEndCut(objects1, objects2, startShift); Ref<Change> changeRef = doBuildChangesFast(objects1.length, objects2.length, startShift, endCut); if (changeRef != null) return changeRef.get(); int trimmedLength = objects1.length + objects2.length - 2 * startShift - 2 * endCut; Enumerator<T> enumerator = new Enumerator<T>(trimmedLength, ContainerUtil.<T>canonicalStrategy()); int[] ints1 = enumerator.enumerate(objects1, startShift, endCut); int[] ints2 = enumerator.enumerate(objects2, startShift, endCut); return doBuildChanges(ints1, ints2, new ChangeBuilder(startShift)); }