Skip to content

Commit

Permalink
Eliminate String::Extend weak reference
Browse files Browse the repository at this point in the history
Rarely used, mostly at boot, and probably just as quick to look up
the constant as go through the weak reference.
  • Loading branch information
headius committed Nov 21, 2024
1 parent cbcc74b commit 8e783d9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 2 additions & 2 deletions java/src/json/ext/GeneratorMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ private static RubyHash toJsonRawObject(ThreadContext context,
}

@JRubyMethod(module=true)
public static IRubyObject included(ThreadContext context, IRubyObject vSelf, IRubyObject module) {
public static IRubyObject included(ThreadContext context, IRubyObject extendModule, IRubyObject module) {
RuntimeInfo info = RuntimeInfo.forRuntime(context.runtime);
return module.callMethod(context, "extend", info.stringExtendModule.get());
return module.callMethod(context, "extend", ((RubyModule) extendModule).getConstant("Extend"));
}
}

Expand Down
2 changes: 0 additions & 2 deletions java/src/json/ext/RuntimeInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ final class RuntimeInfo {
// the Ruby runtime object, which would cause memory leaks in the runtimes map above.
/** JSON */
WeakReference<RubyModule> jsonModule;
/** JSON::Ext::Generator::GeneratorMethods::String::Extend */
WeakReference<RubyModule> stringExtendModule;
/** JSON::Ext::Generator::State */
WeakReference<RubyClass> generatorStateClass;
/** JSON::SAFE_STATE_PROTOTYPE */
Expand Down

0 comments on commit 8e783d9

Please # to comment.