diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-03-28 10:33:43 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-03-28 10:33:43 +0000 |
commit | cb88d47db3306cf8534e2b5b1f0f96b81b302ce3 (patch) | |
tree | ab8eb48b41aeba58c590c2a8b55da7edee9d2e1e /variable.c | |
parent | c2ea99007f0627fcd621bae4799a2b717e0ab829 (diff) | |
download | ruby-cb88d47db3306cf8534e2b5b1f0f96b81b302ce3.tar.gz ruby-cb88d47db3306cf8534e2b5b1f0f96b81b302ce3.tar.xz ruby-cb88d47db3306cf8534e2b5b1f0f96b81b302ce3.zip |
* variable.c (rb_class_path): hold temporary class path in a
instance variable to get rid of GC. [ruby-dev:19932]
* variable.c (classname): remove temporary class path when exact
name found.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@3629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'variable.c')
-rw-r--r-- | variable.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/variable.c b/variable.c index 9ac004e7f..0f5185a5f 100644 --- a/variable.c +++ b/variable.c @@ -156,9 +156,17 @@ classname(klass) } } if (NIL_P(path)) { + ID tmppath = rb_intern("__tmp_classpath__"); + path = find_class_path(klass); if (NIL_P(path)) { - return 0; + if (!RCLASS(klass)->iv_tbl || + !st_lookup(RCLASS(klass)->iv_tbl, tmppath, &path)) { + return 0; + } + } + else if (RCLASS(klass)->iv_tbl) { + st_delete(RCLASS(klass)->iv_tbl, &tmppath, 0); } return path; } @@ -199,6 +207,7 @@ rb_class_path(klass) str = rb_str_new(0, 2 + strlen(s) + 3 + 2 * SIZEOF_LONG + 1); sprintf(RSTRING(str)->ptr, "#<%s:0x%lx>", s, klass); RSTRING(str)->len = strlen(RSTRING(str)->ptr); + rb_iv_set(klass, "__tmp_classpath__", str); return str; } |