summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-05-22 09:48:05 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-05-22 09:48:05 +0000
commite23aac09ca5418997721c75419336f64ef5efe83 (patch)
treedd45543f8997bda7736300647510a94b5121fc0b /variable.c
parent642ca17bdf01376ec1018f7a39fb84123682e370 (diff)
merges r23431 from trunk into ruby_1_9_1.
-- * variable.c (rb_autoload_load): checks if iv_tbl is valid. [ruby-dev:38456] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@23526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/variable.c b/variable.c
index 8b4acc8c7c..5ce48ca872 100644
--- a/variable.c
+++ b/variable.c
@@ -1430,11 +1430,23 @@ autoload_node(VALUE mod, ID id, int noload)
return 0;
}
+static NODE *
+autoload_node_ptr(VALUE mod, ID id)
+{
+ struct st_table *tbl = RCLASS_IV_TBL(mod);
+ st_data_t val;
+
+ if (!tbl || !st_lookup(tbl, id, &val) || val != Qundef) {
+ return 0;
+ }
+ return autoload_node(mod, id, 0);
+}
+
VALUE
rb_autoload_load(VALUE klass, ID id)
{
VALUE file;
- NODE *load = autoload_node(klass, id, 0);
+ NODE *load = autoload_node_ptr(klass, id);
if (!load) return Qfalse;
file = load->nd_lit;
@@ -1444,15 +1456,10 @@ rb_autoload_load(VALUE klass, ID id)
VALUE
rb_autoload_p(VALUE mod, ID id)
{
- struct st_table *tbl = RCLASS_IV_TBL(mod);
- st_data_t val;
- NODE *load;
VALUE file;
+ NODE *load = autoload_node_ptr(mod, id);
- if (!tbl || !st_lookup(tbl, id, &val) || val != Qundef) {
- return Qnil;
- }
- load = autoload_node(mod, id, 0);
+ if (!load) return Qnil;
return load && (file = load->nd_lit) ? file : Qnil;
}