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

Commits on Feb 6, 2015

  1. Copy the full SHA
    ff11180 View commit details
  2. 2
    Copy the full SHA
    c08e59b View commit details
Showing with 15 additions and 9 deletions.
  1. +0 −6 spec/truffle/tags/core/string/start_with_tags.txt
  2. +15 −3 truffle/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java
6 changes: 0 additions & 6 deletions spec/truffle/tags/core/string/start_with_tags.txt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1522,22 +1522,34 @@ private RubyArray splitHelper(RubyString string, String sep) {
}
}

@CoreMethod(names = "start_with?", required = 1)
@CoreMethod(names = "start_with?", argumentsAsArray = true)
public abstract static class StartWithNode extends CoreMethodNode {

@Child private ToStrNode toStrNode;

public StartWithNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
toStrNode = insert(ToStrNodeFactory.create(getContext(), getSourceSection(), null));
}

public StartWithNode(StartWithNode prev) {
super(prev);
toStrNode = prev.toStrNode;
}

@Specialization
public boolean endWith(RubyString string, RubyString b) {
public boolean startWith(VirtualFrame frame, RubyString string, Object... prefixes) {
notDesignedForCompilation();

return string.toString().startsWith(b.toString());
for (Object prefix : prefixes) {
final RubyString coerced = toStrNode.executeRubyString(frame, prefix);

if (string.toString().startsWith(coerced.toString())) {
return true;
}
}

return false;
}
}