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: 04d47df399bf
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2e8998243079
Choose a head ref
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on Jan 10, 2017

  1. Copy the full SHA
    a7b568b View commit details
  2. Copy the full SHA
    2e89982 View commit details
Showing with 12 additions and 20 deletions.
  1. +12 −20 truffle/src/main/java/org/jruby/truffle/core/string/StringNodes.java
Original file line number Diff line number Diff line change
@@ -1371,7 +1371,8 @@ public abstract static class ScrubNode extends PrimitiveArrayArgumentsNode {
public DynamicObject scrubAsciiCompat(VirtualFrame frame, DynamicObject string, Object repl, DynamicObject block) {
final Rope rope = rope(string);
final Encoding enc = rope.getEncoding();
Rope buf = null;
boolean foundInvalidChar = false;
Rope buf = RopeConstants.EMPTY_ASCII_8BIT_ROPE;

final byte[] pBytes = rope.getBytes();
final int e = pBytes.length;
@@ -1393,10 +1394,8 @@ public DynamicObject scrubAsciiCompat(VirtualFrame frame, DynamicObject string,
// p1~p: valid ascii/multibyte chars
// p ~e: invalid bytes + unknown bytes
int clen = enc.maxLength();
if (buf == null) {
buf = RopeConstants.EMPTY_ASCII_8BIT_ROPE;
}
if (p > p1) {
foundInvalidChar = true;
if (p1 < p) {
buf = makeConcatNode.executeMake(buf, RopeOperations.create(ArrayUtils.extractRange(pBytes, p1, p), enc, CodeRange.CR_VALID), enc);
}

@@ -1429,11 +1428,8 @@ public DynamicObject scrubAsciiCompat(VirtualFrame frame, DynamicObject string,
}
}
}
if (buf == null) {
if (p == e) {
return nil();
}
buf = RopeConstants.EMPTY_ASCII_8BIT_ROPE;
if (!foundInvalidChar && p == e) {
return nil();
}
if (p1 < p) {
buf = makeConcatNode.executeMake(buf, RopeOperations.create(ArrayUtils.extractRange(pBytes, p1, p), enc, CodeRange.CR_VALID), enc);
@@ -1451,7 +1447,8 @@ public DynamicObject scrubAsciiCompat(VirtualFrame frame, DynamicObject string,
public DynamicObject scrubAscciIncompatible(VirtualFrame frame, DynamicObject string, Object repl, DynamicObject block) {
final Rope rope = rope(string);
final Encoding enc = rope.getEncoding();
Rope buf = null;
boolean foundInvalidChar = false;
Rope buf = RopeConstants.EMPTY_ASCII_8BIT_ROPE;

final byte[] pBytes = rope.getBytes();
final int e = pBytes.length;
@@ -1467,13 +1464,11 @@ public DynamicObject scrubAscciIncompatible(VirtualFrame frame, DynamicObject st
} else if (MBCLEN_CHARFOUND_P(ret)) {
p += MBCLEN_CHARFOUND_LEN(ret);
} else if (MBCLEN_INVALID_P(ret)) {
foundInvalidChar = true;
final int q = p;
int clen = enc.maxLength();
if (buf == null) {
buf = RopeConstants.EMPTY_ASCII_8BIT_ROPE;
}

if (p > p1) {
if (p1 < p) {
buf = makeConcatNode.executeMake(buf, RopeOperations.create(ArrayUtils.extractRange(pBytes, p1, p), enc, CodeRange.CR_VALID), enc);
}

@@ -1501,11 +1496,8 @@ public DynamicObject scrubAscciIncompatible(VirtualFrame frame, DynamicObject st
p1 = p;
}
}
if (buf == null) {
if (p == e) {
return nil();
}
buf = RopeConstants.EMPTY_ASCII_8BIT_ROPE;
if (!foundInvalidChar && p == e) {
return nil();
}
if (p1 < p) {
buf = makeConcatNode.executeMake(buf, RopeOperations.create(ArrayUtils.extractRange(pBytes, p1, p), enc, CodeRange.CR_VALID), enc);