Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Truffle] Use Array.getLength to avoid duplicating assertions.
  • Loading branch information
eregon committed Jan 13, 2015
1 parent 5f6aa00 commit 122c81b
Showing 1 changed file with 4 additions and 30 deletions.
34 changes: 4 additions & 30 deletions core/src/main/java/org/jruby/truffle/runtime/util/ArrayUtils.java
Expand Up @@ -14,6 +14,7 @@
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.RubyArguments;

import java.lang.reflect.Array;
import java.util.Arrays;

public abstract class ArrayUtils {
Expand All @@ -33,15 +34,6 @@ public static int[] extractRange(int[] source, int start, int end) {
return result;
}

private static boolean checkExtractRangeArgs(int[] source, int start, int end) {
assert source != null;
assert start >= 0;
assert start <= source.length;
assert end >= start;
assert end <= source.length;
return true;
}

/**
* Extracts part of an array into a newly allocated Object[] array. Does not perform safety checks on parameters.
* @param source the source array whose values should be extracted
Expand All @@ -57,15 +49,6 @@ public static long[] extractRange(long[] source, int start, int end) {
return result;
}

private static boolean checkExtractRangeArgs(long[] source, int start, int end) {
assert source != null;
assert start >= 0;
assert start <= source.length;
assert end >= start;
assert end <= source.length;
return true;
}

/**
* Extracts part of an array into a newly allocated Object[] array. Does not perform safety checks on parameters.
* @param source the source array whose values should be extracted
Expand All @@ -81,15 +64,6 @@ public static double[] extractRange(double[] source, int start, int end) {
return result;
}

private static boolean checkExtractRangeArgs(double[] source, int start, int end) {
assert source != null;
assert start >= 0;
assert start <= source.length;
assert end >= start;
assert end <= source.length;
return true;
}

/**
* Extracts part of an array into a newly allocated Object[] array. Does not perform safety checks on parameters.
* @param source the source array whose values should be extracted
Expand All @@ -105,12 +79,12 @@ public static Object[] extractRange(Object[] source, int start, int end) {
return result;
}

private static boolean checkExtractRangeArgs(Object[] source, int start, int end) {
private static boolean checkExtractRangeArgs(Object source, int start, int end) {
assert source != null;
assert start >= 0;
assert start <= source.length;
assert start <= Array.getLength(source);
assert end >= start;
assert end <= source.length;
assert end <= Array.getLength(source);
return true;
}

Expand Down

0 comments on commit 122c81b

Please sign in to comment.