New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Java's Arrays.sort #3961

Merged
merged 2 commits into from Jun 15, 2016
Jump to file or symbol
Failed to load files and symbols.
+3 −4
Diff settings

Always

Just for now

@@ -57,7 +57,6 @@
import org.jruby.runtime.marshal.UnmarshalStream;
import org.jruby.util.ByteList;
import org.jruby.util.Pack;
import org.jruby.util.Qsort;
import org.jruby.util.RecursiveComparator;
import org.jruby.util.TypeConverter;
import org.jruby.util.io.EncodingUtils;
@@ -3275,7 +3274,7 @@ private IRubyObject sortInternal(final ThreadContext context, boolean honorOverr
final boolean stringBypass = !honorOverride || runtime.getString().isMethodBuiltin("<=>");
try {
Qsort.sort(values, begin, begin + realLength, new Comparator() {
Arrays.sort(values, begin, begin + realLength, new Comparator() {
public int compare(Object o1, Object o2) {
if (fixnumBypass && o1 instanceof RubyFixnum && o2 instanceof RubyFixnum) {
return compareFixnums((RubyFixnum) o1, (RubyFixnum) o2);
@@ -3310,7 +3309,7 @@ private IRubyObject sortInternal(final ThreadContext context, final Block block)
int length = realLength;
safeArrayCopy(values, begin, newValues, 0, length);
Qsort.sort(newValues, 0, length, new Comparator() {
Arrays.sort(newValues, 0, length, new Comparator() {
public int compare(Object o1, Object o2) {
IRubyObject obj1 = (IRubyObject) o1;
IRubyObject obj2 = (IRubyObject) o2;
@@ -30,6 +30,7 @@
import java.util.ArrayList;
import java.util.Comparator;
@Deprecated
public class Qsort {
private static final int SIZE_THRESHOLD = 16;
@@ -287,4 +288,3 @@ private static void swap(Object[] a, int i, int j) {
a[j] = t;
}
}
ProTip! Use n and p to navigate between commits in a pull request.