ruby-changes:56198
From: Nobuyoshi <ko1@a...>
Date: Sun, 23 Jun 2019 01:47:44 +0900 (JST)
Subject: [ruby-changes:56198] Nobuyoshi Nakada: 151843b981 (trunk): Hoisted out autoloading_const_entry
https://git.ruby-lang.org/ruby.git/commit/?id=151843b981 From 151843b9816b52b1ddb1e9b2040991a7de4173c6 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Thu, 13 Dec 2018 18:12:07 +0900 Subject: Hoisted out autoloading_const_entry diff --git a/variable.c b/variable.c index 7c08579..6394e01 100644 --- a/variable.c +++ b/variable.c @@ -2138,9 +2138,26 @@ check_autoload_required(VALUE mod, ID id, const char **loadingpath) https://github.com/ruby/ruby/blob/trunk/variable.c#L2138 return 0; } +struct autoload_const *autoloading_const_entry(VALUE mod, ID id); + MJIT_FUNC_EXPORTED int rb_autoloading_value(VALUE mod, ID id, VALUE* value, rb_const_flag_t *flag) { + struct autoload_const *ac = autoloading_const_entry(mod, id); + if (!ac) return FALSE; + + if (value) { + *value = ac->value; + } + if (flag) { + *flag = ac->flag; + } + return TRUE; +} + +struct autoload_const * +autoloading_const_entry(VALUE mod, ID id) +{ VALUE load = autoload_data(mod, id); struct autoload_data_i *ele; struct autoload_const *ac; @@ -2151,13 +2168,7 @@ rb_autoloading_value(VALUE mod, ID id, VALUE* value, rb_const_flag_t *flag) https://github.com/ruby/ruby/blob/trunk/variable.c#L2168 if (ele->state && ele->state->thread == rb_thread_current()) { if (ac->value != Qundef) { - if (value) { - *value = ac->value; - } - if (flag) { - *flag = ac->flag; - } - return 1; + return ac; } } return 0; @@ -2395,9 +2406,11 @@ rb_const_search(VALUE klass, ID id, int exclude, int recurse, int visibility) https://github.com/ruby/ruby/blob/trunk/variable.c#L2406 rb_const_warn_if_deprecated(ce, tmp, id); value = ce->value; if (value == Qundef) { + struct autoload_const *ac; if (am == tmp) break; am = tmp; - if (rb_autoloading_value(tmp, id, &av, &flag)) return av; + ac = autoloading_const_entry(tmp, id); + if (ac) return ac->value; rb_autoload_load(tmp, id); continue; } -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/