Skip to content

Commit e16ff26

Browse files
committed
[refactor] avoid setCallInfo usage in JRubyMethod
1 parent 7d60415 commit e16ff26

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

core/src/main/java/org/jruby/RubyData.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public static RubyHash deconstruct_keys(ThreadContext context, IRubyObject self,
239239
@JRubyMethod(keywords = true, optional = 1, checkArity = false)
240240
public static IRubyObject with(ThreadContext context, IRubyObject self, IRubyObject[] args) {
241241
IRubyObject kwargs = IRRuntimeHelpers.receiveKeywords(context, args, false, true, false);
242-
if (kwargs == UndefinedValue.UNDEFINED || kwargs.isNil()) {
242+
if (!(kwargs instanceof RubyHash)) {
243243
checkArgumentCount(context, args.length, 0, 0);
244244
return self;
245245
}
@@ -249,7 +249,7 @@ public static IRubyObject with(ThreadContext context, IRubyObject self, IRubyObj
249249
RubyHash kwargsHash = (RubyHash) kwargs;
250250
RubyHash h = to_h(context, self, Block.NULL_BLOCK);
251251
h.addAll(context, kwargsHash);
252-
setCallInfo(context, CALL_KEYWORD);
252+
context.callInfo = CALL_KEYWORD;
253253
return DataMethods.rbNew(context, self.getMetaClass(), h);
254254
}
255255

@@ -277,7 +277,7 @@ public static IRubyObject rbNew(ThreadContext context, IRubyObject self, IRubyOb
277277

278278
IRubyObject dataObject = klass.getAllocator().allocate(context.runtime, klass);
279279

280-
setCallInfo(context, ThreadContext.CALL_KEYWORD);
280+
context.callInfo = ThreadContext.CALL_KEYWORD;
281281

282282
// TODO: avoid initialize and hash overhead for known types
283283
dataObject.getMetaClass().getBaseCallSite(RubyClass.CS_IDX_INITIALIZE)
@@ -326,7 +326,7 @@ public static IRubyObject rbNew(ThreadContext context, IRubyObject self, IRubyOb
326326

327327
IRubyObject dataObject = klass.getAllocator().allocate(context.runtime, klass);
328328

329-
setCallInfo(context, callInfo);
329+
context.callInfo = callInfo;
330330

331331
// TODO: avoid initialize and hash overhead for known types
332332
dataObject.getMetaClass().getBaseCallSite(RubyClass.CS_IDX_INITIALIZE)

core/src/main/java/org/jruby/RubyFile.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ public IRubyObject flock(ThreadContext context, IRubyObject operation) {
299299
@JRubyMethod(name = "initialize", required = 1, optional = 3, checkArity = false, visibility = PRIVATE, keywords = true)
300300
public IRubyObject initialize(ThreadContext context, IRubyObject[] args, Block block) {
301301
// capture callInfo for delegating to IO#initialize
302-
int callInfo = context.callInfo;
302+
final int callInfo = context.callInfo;
303303
IRubyObject keywords = IRRuntimeHelpers.receiveKeywords(context, args, false, true, false);
304304
// Mild hack. We want to arity-mismatch if extra arg is not really a kwarg but not if it is one.
305305
int maxArgs = keywords instanceof RubyHash ? 4 : 3;
@@ -311,7 +311,7 @@ public IRubyObject initialize(ThreadContext context, IRubyObject[] args, Block b
311311
IRubyObject fd = TypeConverter.convertToTypeWithCheck(context, args[0], context.runtime.getFixnum(), sites(context).to_int_checked);
312312
if (!fd.isNil()) {
313313
// restore callInfo for delegated call to IO#initialize
314-
IRRuntimeHelpers.setCallInfo(context, callInfo);
314+
context.callInfo = callInfo;
315315
return switch (argc) {
316316
case 1 -> super.initialize(context, fd, block);
317317
case 2 -> super.initialize(context, fd, args[1], block);

0 commit comments

Comments
 (0)