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

Commits on Jan 10, 2017

  1. [Truffle] Use a Proc instead of a lambda as they currently (incorrect…

    …ly) swallow the break.
    eregon committed Jan 10, 2017
    Copy the full SHA
    0dd40b4 View commit details
  2. Copy the full SHA
    4ea7ec3 View commit details
Showing with 4 additions and 20 deletions.
  1. +2 −18 truffle/src/main/java/org/jruby/truffle/core/string/StringNodes.java
  2. +2 −2 truffle/src/main/ruby/core/string.rb
Original file line number Diff line number Diff line change
@@ -75,18 +75,13 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.DirectCallNode;
import com.oracle.truffle.api.nodes.IndirectCallNode;
import com.oracle.truffle.api.nodes.Node.Child;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.profiles.ConditionProfile;
import org.jcodings.Encoding;
import org.jcodings.exception.EncodingException;
import org.jcodings.specific.ASCIIEncoding;
import org.jcodings.specific.USASCIIEncoding;
import org.jcodings.specific.UTF16BEEncoding;
import org.jcodings.specific.UTF16LEEncoding;
import org.jcodings.specific.UTF32BEEncoding;
import org.jcodings.specific.UTF32LEEncoding;
import org.jcodings.specific.UTF8Encoding;
import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
@@ -154,8 +149,6 @@
import java.util.Arrays;
import java.util.List;

import static org.jruby.truffle.core.rope.CodeRange.CR_7BIT;
import static org.jruby.truffle.core.rope.CodeRange.CR_VALID;
import static org.jruby.truffle.core.rope.RopeConstants.EMPTY_ASCII_8BIT_ROPE;
import static org.jruby.truffle.core.string.StringOperations.encoding;
import static org.jruby.truffle.core.string.StringOperations.rope;
@@ -1368,17 +1361,13 @@ private int prevCharHead(Encoding enc, byte[]bytes, int p, int s, int end) {
}

@Primitive(name = "string_scrub")
@ImportStatic(StringGuards.class)
public abstract static class ScrubNode extends PrimitiveArrayArgumentsNode {

@Child private YieldNode yieldNode = new YieldNode();
@Child private RopeNodes.MakeConcatNode makeConcatNode = RopeNodesFactory.MakeConcatNodeGen.create(null, null, null);

@Specialization(guards = "isValid(string)")
public DynamicObject scrubValid(VirtualFrame frame, DynamicObject string, Object repl, DynamicObject block) {
return nil();
}

@Specialization(guards = "!isValid(string)")
@Specialization(guards = { "!is7Bit(string)", "!isValidCodeRange(string)" })
public DynamicObject scrubDefault(VirtualFrame frame, DynamicObject string, Object repl, DynamicObject block,
@Cached("createBinaryProfile()") ConditionProfile asciiCompatibleProfile) {
final Rope rope = rope(string);
@@ -1523,11 +1512,6 @@ public DynamicObject scrubDefault(VirtualFrame frame, DynamicObject string, Obje
return createString(buf);
}

protected boolean isValid(DynamicObject string) {
CodeRange cr = rope(string).getCodeRange();
return cr == CR_7BIT || cr == CR_VALID;
}

public Object yield(VirtualFrame frame, DynamicObject block, Object... arguments) {
return yieldNode.dispatch(frame, block, arguments);
}
4 changes: 2 additions & 2 deletions truffle/src/main/ruby/core/string.rb
Original file line number Diff line number Diff line change
@@ -1211,9 +1211,9 @@ def scrub(replace = nil, &block)
replace_block = if replace
replace = str_compat_and_valid(replace, encoding)
taint = true if replace.tainted?
-> broken { replace }
Proc.new { |broken| replace }
else
-> broken {
Proc.new { |broken|
replacement = block.call(broken)
replacement = str_compat_and_valid(replacement, encoding)
taint = true if replacement.tainted?