Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 33e9e3a9e8cc
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7b755ba55a9c
Choose a head ref
  • 11 commits
  • 8 files changed
  • 1 contributor

Commits on Dec 23, 2016

  1. Copy the full SHA
    0e6845b View commit details
  2. Copy the full SHA
    4cf3007 View commit details
  3. Copy the full SHA
    73bb0a3 View commit details
  4. Copy the full SHA
    86823a8 View commit details
  5. Copy the full SHA
    78cc0dc View commit details
  6. Copy the full SHA
    8cefb02 View commit details
  7. Copy the full SHA
    a00f144 View commit details
  8. Copy the full SHA
    a0f2b65 View commit details
  9. Copy the full SHA
    483388a View commit details
  10. Copy the full SHA
    5d69f23 View commit details
  11. Copy the full SHA
    7b755ba View commit details
21 changes: 18 additions & 3 deletions truffle/src/main/java/org/jruby/truffle/core/array/ArrayUtils.java
Original file line number Diff line number Diff line change
@@ -20,7 +20,22 @@ public abstract class ArrayUtils {
public static final Object[] EMPTY_ARRAY = new Object[0];

/**
* Extracts part of an array into a newly allocated Object[] array. Does not perform safety checks on parameters.
* Extracts part of an array into a newly allocated byte[] array. Does not perform safety checks on parameters.
* @param source the source array whose values should be extracted
* @param start the start index, must be >= 0 and <= source.length
* @param end the end index (exclusive), must be >= 0 and <= source.length and >= start
* @return a newly allocated array with the extracted elements and length (end - start)
*/
public static byte[] extractRange(byte[] source, int start, int end) {
assert assertExtractRangeArgs(source, start, end);
int length = end - start;
byte[] result = new byte[length];
System.arraycopy(source, start, result, 0, length);
return result;
}

/**
* Extracts part of an array into a newly allocated int[] array. Does not perform safety checks on parameters.
* @param source the source array whose values should be extracted
* @param start the start index, must be >= 0 and <= source.length
* @param end the end index (exclusive), must be >= 0 and <= source.length and >= start
@@ -35,7 +50,7 @@ public static int[] extractRange(int[] source, int start, int end) {
}

/**
* Extracts part of an array into a newly allocated Object[] array. Does not perform safety checks on parameters.
* Extracts part of an array into a newly allocated long[] array. Does not perform safety checks on parameters.
* @param source the source array whose values should be extracted
* @param start the start index, must be >= 0 and <= source.length
* @param end the end index (exclusive), must be >= 0 and <= source.length and >= start
@@ -50,7 +65,7 @@ public static long[] extractRange(long[] source, int start, int end) {
}

/**
* Extracts part of an array into a newly allocated Object[] array. Does not perform safety checks on parameters.
* Extracts part of an array into a newly allocated double[] array. Does not perform safety checks on parameters.
* @param source the source array whose values should be extracted
* @param start the start index, must be >= 0 and <= source.length
* @param end the end index (exclusive), must be >= 0 and <= source.length and >= start
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.object.DynamicObject;
import org.jcodings.Encoding;
import org.jcodings.ascii.AsciiTables;
import org.jcodings.specific.ASCIIEncoding;
import org.jcodings.specific.USASCIIEncoding;
import org.jcodings.specific.UTF8Encoding;
@@ -611,4 +612,27 @@ private static CodeRange commonCodeRange(CodeRange first, CodeRange second) {
return CR_VALID;
}

@TruffleBoundary
public static int caseInsensitiveCmp(Rope value, Rope other) {
// Taken from org.jruby.util.ByteList#caseInsensitiveCmp.

if (other == value) return 0;

final int size = value.byteLength();
final int len = Math.min(size, other.byteLength());
final byte[] other_bytes = other.getBytes();

for (int offset = -1; ++offset < len;) {
int myCharIgnoreCase = AsciiTables.ToLowerCaseTable[value.getBytes()[offset] & 0xff] & 0xff;
int otherCharIgnoreCase = AsciiTables.ToLowerCaseTable[other_bytes[offset] & 0xff] & 0xff;
if (myCharIgnoreCase < otherCharIgnoreCase) {
return -1;
} else if (myCharIgnoreCase > otherCharIgnoreCase) {
return 1;
}
}

return size == other.byteLength() ? 0 : size == len ? -1 : 1;
}

}
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ public class CoreStrings {
public final CoreString FALSE;
public final CoreString GLOBAL_VARIABLE;
public final CoreString INSTANCE_VARIABLE;
public final CoreString INVALID_VALUE_FOR_FLOAT;
public final CoreString LINE;
public final CoreString LOCAL_VARIABLE;
public final CoreString METHOD;
@@ -58,6 +59,7 @@ public CoreStrings(RubyContext context) {
FALSE = new CoreString(context, "false");
GLOBAL_VARIABLE = new CoreString(context, "global-variable");
INSTANCE_VARIABLE = new CoreString(context, "instance-variable");
INVALID_VALUE_FOR_FLOAT = new CoreString(context, "invalid value for Float()");
LINE = new CoreString(context, "line");
LOCAL_VARIABLE = new CoreString(context, "local-variable");
METHOD = new CoreString(context, "method");
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@
***** END LICENSE BLOCK *****/
package org.jruby.truffle.core.string;

import org.jruby.truffle.core.rope.Rope;
import org.jruby.truffle.core.string.ByteList;
import org.jruby.truffle.parser.SafeDoubleParser;

@@ -57,16 +58,16 @@ public class DoubleConverter {
public DoubleConverter() {
}

public void init(ByteList list, boolean isStrict) {
bytes = list.getUnsafeBytes();
index = list.begin();
endIndex = index + list.length();
public void init(Rope rope, boolean isStrict) {
bytes = rope.getBytes();
index = 0;
endIndex = index + rope.byteLength();
this.isStrict = isStrict;
// +2 for added exponent: E...
// The algorithm trades digits for inc/dec exponent.
// Worse case is adding E-1 when no exponent,
// it trades one digit for 3 chars.
chars = new char[Math.min(list.length() + 2, MAX_LENGTH)];
chars = new char[Math.min(rope.byteLength() + 2, MAX_LENGTH)];
charsIndex = 0;
significantDigitsProcessed = 0;
adjustExponent = 0;
@@ -179,8 +180,8 @@ private boolean strictError() {
* However, in order to maintain binary compatibility with extensions we can't
* just change the signature either.
*/
public double parse(ByteList list, boolean strict, boolean is19) {
init(list, strict);
public double parse(Rope rope, boolean strict, boolean is19) {
init(rope, strict);

if (skipWhitespace()) return completeCalculation();
if (parseOptionalSign()) return completeCalculation();

This file was deleted.

Loading