Skip to content

Commit

Permalink
Use a respond_to site for path check
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Sep 19, 2023
1 parent 1c7dd96 commit 1330f22
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ext/java/org/jruby/ext/psych/PsychParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.jruby.javasupport.JavaUtil;
import org.jruby.runtime.Block;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.JavaSites;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.callsite.CachingCallSite;
Expand Down Expand Up @@ -248,8 +249,9 @@ public IRubyObject parse(ThreadContext context, IRubyObject handler, IRubyObject
LoadSettings loadSettings = loadSettingsBuilder.build();
parser = new ParserImpl(loadSettings, new ScannerImpl(loadSettings, readerFor(context, yaml, loadSettings)));

if (path.isNil() && yaml.respondsTo("path")) {
path = sites.path.call(context, this, yaml);
JavaSites.CheckedSites pathSites = sites.path;
if (path.isNil() && pathSites.respond_to_X.respondsTo(context, yaml, yaml)) {
path = pathSites.site.call(context, this, yaml);
}

while (parser.hasNext()) {
Expand Down Expand Up @@ -651,7 +653,7 @@ private LoadSettings buildSettings() {
private final CallSites sites;

private static class CallSites {
private final CachingCallSite path = new FunctionalCachingCallSite("path");
private final JavaSites.CheckedSites path = new JavaSites.CheckedSites("path");
private final CachingCallSite event_location = new FunctionalCachingCallSite("event_location");
private final CachingCallSite start_stream = new FunctionalCachingCallSite("start_stream");
private final CachingCallSite start_document = new FunctionalCachingCallSite("start_document");
Expand Down

0 comments on commit 1330f22

Please sign in to comment.