From b4ab650e1ab3b1961a8aea8bc510cc041045a7db Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 9 Dec 2013 03:25:38 +0000 Subject: variable.c: rb_class_path_cached * variable.c (rb_class_path_cached): returns cached class path only, without searching and allocating new class path string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- variable.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'variable.c') diff --git a/variable.c b/variable.c index ded150e30c..5d200bb992 100644 --- a/variable.c +++ b/variable.c @@ -277,6 +277,18 @@ rb_class_path_no_cache(VALUE klass) return path; } +VALUE +rb_class_path_cached(VALUE klass) +{ + st_table *ivtbl = RCLASS_IV_TBL(klass); + st_data_t n; + + if (!ivtbl) return Qnil; + if (st_lookup(ivtbl, (st_data_t)classpath, &n)) return (VALUE)n; + if (st_lookup(ivtbl, (st_data_t)tmp_classpath, &n)) return (VALUE)n; + return Qnil; +} + void rb_set_class_path_string(VALUE klass, VALUE under, VALUE name) { -- cgit v1.2.3