moved min to ArrayUtil

This commit is contained in:
Alexey Kudravtsev
2016-08-15 16:55:00 +03:00
parent 07e9e9f74e
commit 890bed7288
2 changed files with 12 additions and 16 deletions
@@ -17,7 +17,6 @@ package com.intellij.diff.tools.util;
import com.intellij.diff.util.Side;
import com.intellij.diff.util.ThreeSide;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.LogicalPosition;
import com.intellij.openapi.editor.ScrollingModel;
@@ -25,6 +24,7 @@ import com.intellij.openapi.editor.event.VisibleAreaEvent;
import com.intellij.openapi.editor.event.VisibleAreaListener;
import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.editor.impl.FoldingModelImpl;
import com.intellij.util.ArrayUtil;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.CalledInAwt;
import org.jetbrains.annotations.NotNull;
@@ -35,8 +35,6 @@ import java.awt.*;
import java.util.List;
public class SyncScrollSupport {
private static final Logger LOG = Logger.getInstance(SyncScrollSupport.class);
public interface SyncScrollable {
@CalledInAwt
boolean isSyncScrollEnabled();
@@ -287,9 +285,7 @@ public class SyncScrollSupport {
doScrollVertically(editor, offsets[i], animateSlaves);
editor.getScrollingModel().runActionOnScrollingFinished(() -> {
exitDisableScrollSection();
});
editor.getScrollingModel().runActionOnScrollingFinished(this::exitDisableScrollSection);
}
}
});
@@ -459,10 +455,10 @@ public class SyncScrollSupport {
topShifts[i] = canShow ? Math.min(editorHeights[i] - gapLines[i] - rangeHeights[i], shift) : gapLines[i];
}
int topShift = min(topShifts);
int topShift = ArrayUtil.min(topShifts);
// check if we're at the top of file
topShift = Math.min(topShift, min(topOffsets));
topShift = Math.min(topShift, ArrayUtil.min(topOffsets));
int[] offsets = new int[count];
boolean haveEnoughSpace = true;
@@ -490,14 +486,6 @@ public class SyncScrollSupport {
return offsets;
}
private static int min(int[] values) {
int min = Integer.MAX_VALUE;
for (int value : values) {
if (value < min) min = value;
}
return min;
}
private static class Anchor {
public final int masterStartOffset;
public final int masterEndOffset;
@@ -944,4 +944,12 @@ public class ArrayUtil extends ArrayUtilRt {
int middlePartLength = n / part;
return middlePartLength == 0 ? 0 : total / middlePartLength;
}
public static int min(int[] values) {
int min = Integer.MAX_VALUE;
for (int value : values) {
if (value < min) min = value;
}
return min;
}
}