@@ -2893,31 +2893,27 @@ public IRubyObject smartLoadNewUser(IRubyObject target, IRubyObject data) {
28932893 */
28942894 public IRubyObject smartLoadOldUser (IRubyObject data ) {
28952895 ThreadContext context = runtime .getCurrentContext ();
2896- CacheEntry cache ;
2897- if ((cache = getSingletonClass ().cachedLoad ).token == getSingletonClass ().generation ) {
2898- return cache .method .call (context , this , cache .sourceModule , "_load" , data );
2899- } else {
2900- cache = getSingletonClass ().searchWithCache ("respond_to?" );
2901- DynamicMethod method = cache .method ;
2902- if (!method .equals (runtime .getRespondToMethod ()) && !method .isUndefined ()) {
2903-
2904- // custom respond_to?, cache nothing and use slow path
2905- if (method .call (context , this , cache .sourceModule , "respond_to?" , asSymbol (context , "_load" )).isTrue ()) {
2906- return callMethod (context , "_load" , data );
2907- } else {
2908- throw typeError (context , "class " , this , " needs to have method `_load'" );
2909- }
2910-
2911- } else if (!(cache = getSingletonClass ().searchWithCache ("_load" )).method .isUndefined ()) {
2912-
2913- // real _load defined, cache and call it
2914- getSingletonClass ().cachedLoad = cache ;
2915- return cache .method .call (context , this , cache .sourceModule , "_load" , data );
2916-
2896+ var singleton = singletonClass (context );
2897+ CacheEntry cache = singleton .cachedLoad ;
2898+ if (cache .token == singleton .generation ) return cache .method .call (context , this , cache .sourceModule , "_load" , data );
2899+
2900+ cache = singleton .searchWithCache ("respond_to?" );
2901+ DynamicMethod method = cache .method ;
2902+ if (!method .equals (runtime .getRespondToMethod ()) && !method .isUndefined ()) {
2903+ // custom respond_to?, cache nothing and use slow path
2904+ if (method .call (context , this , cache .sourceModule , "respond_to?" , asSymbol (context , "_load" )).isTrue ()) {
2905+ return callMethod (context , "_load" , data );
29172906 } else {
2918- // provide an error, since it doesn't exist
29192907 throw typeError (context , "class " , this , " needs to have method `_load'" );
29202908 }
2909+ } else if (!(cache = singleton .searchWithCache ("_load" )).method .isUndefined ()) {
2910+ // real _load defined, cache and call it
2911+ singleton .cachedLoad = cache ;
2912+ return cache .method .call (context , this , cache .sourceModule , "_load" , data );
2913+
2914+ } else {
2915+ // provide an error, since it doesn't exist
2916+ throw typeError (context , "class " , this , " needs to have method `_load'" );
29212917 }
29222918 }
29232919
0 commit comments