From 8e783d953f2d6950bfc69ff36644ad5ec80bef9e Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Thu, 21 Nov 2024 17:21:41 -0600 Subject: [PATCH] Eliminate String::Extend weak reference Rarely used, mostly at boot, and probably just as quick to look up the constant as go through the weak reference. --- java/src/json/ext/GeneratorMethods.java | 4 ++-- java/src/json/ext/RuntimeInfo.java | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/java/src/json/ext/GeneratorMethods.java b/java/src/json/ext/GeneratorMethods.java index 81f01162..8e0ac1e7 100644 --- a/java/src/json/ext/GeneratorMethods.java +++ b/java/src/json/ext/GeneratorMethods.java @@ -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")); } } diff --git a/java/src/json/ext/RuntimeInfo.java b/java/src/json/ext/RuntimeInfo.java index f430a64c..f712dc25 100644 --- a/java/src/json/ext/RuntimeInfo.java +++ b/java/src/json/ext/RuntimeInfo.java @@ -28,8 +28,6 @@ final class RuntimeInfo { // the Ruby runtime object, which would cause memory leaks in the runtimes map above. /** JSON */ WeakReference jsonModule; - /** JSON::Ext::Generator::GeneratorMethods::String::Extend */ - WeakReference stringExtendModule; /** JSON::Ext::Generator::State */ WeakReference generatorStateClass; /** JSON::SAFE_STATE_PROTOTYPE */