This commit is contained in:
Alexey Kudravtsev
2017-05-09 14:49:39 +03:00
parent a89c643f3c
commit 205bef8c2b
3 changed files with 11 additions and 17 deletions
@@ -19,6 +19,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.Collection;
@FunctionalInterface
public interface SweepProcessor<T> {
boolean process(int offset, @NotNull T interval, boolean atStart, @NotNull Collection<T> overlappingIntervals);
}
@@ -307,10 +307,6 @@ public class RangeMarkerTree<T extends RangeMarkerEx> extends IntervalTreeImpl<T
return norm;
}
public boolean sweep(final int start, final int end, @NotNull SweepProcessor<T> sweepProcessor) {
return sweep(processor -> processOverlappingWith(start, end, processor), sweepProcessor);
}
@FunctionalInterface
public interface Generator<T> {
boolean generateInStartOffsetOrder(@NotNull Processor<T> processor);
@@ -95,16 +95,7 @@ public final class LoadTextUtil {
prev = c;
}
String detectedLineSeparator = null;
if (crlfCount > crCount && crlfCount > lfCount) {
detectedLineSeparator = "\r\n";
}
else if (crCount > lfCount) {
detectedLineSeparator = "\r";
}
else if (lfCount > 0) {
detectedLineSeparator = "\n";
}
String detectedLineSeparator = guessLineSeparator(crCount, lfCount, crlfCount);
CharSequence result = buffer.length() == dst ? buffer : buffer.subSequence(0, dst);
return Pair.create(result, detectedLineSeparator);
@@ -151,6 +142,14 @@ public final class LoadTextUtil {
prev = c;
}
String detectedLineSeparator = guessLineSeparator(crCount, lfCount, crlfCount);
ByteArrayCharSequence sequence = new ByteArrayCharSequence(result, 0, dst);
return Pair.create(sequence, detectedLineSeparator);
}
@Nullable
private static String guessLineSeparator(int crCount, int lfCount, int crlfCount) {
String detectedLineSeparator = null;
if (crlfCount > crCount && crlfCount > lfCount) {
detectedLineSeparator = "\r\n";
@@ -161,9 +160,7 @@ public final class LoadTextUtil {
else if (lfCount > 0) {
detectedLineSeparator = "\n";
}
ByteArrayCharSequence sequence = new ByteArrayCharSequence(result, 0, dst);
return Pair.create(sequence, detectedLineSeparator);
return detectedLineSeparator;
}
// private fake charsets for files which have one-byte-for-ascii-characters encoding but contain seven bits characters only. used for optimization since we don't have to encode-decode bytes here.