[前][次][番号順一覧][スレッド一覧]

ruby-changes:32008

From: nobu <ko1@a...>
Date: Mon, 9 Dec 2013 12:25:46 +0900 (JST)
Subject: [ruby-changes:32008] nobu:r44087 (trunk): variable.c: rb_class_path_cached

nobu	2013-12-09 12:25:38 +0900 (Mon, 09 Dec 2013)

  New Revision: 44087

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44087

  Log:
    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.

  Modified files:
    trunk/ChangeLog
    trunk/include/ruby/intern.h
    trunk/variable.c
Index: include/ruby/intern.h
===================================================================
--- include/ruby/intern.h	(revision 44086)
+++ include/ruby/intern.h	(revision 44087)
@@ -888,6 +888,7 @@ struct timespec rb_time_timespec(VALUE t https://github.com/ruby/ruby/blob/trunk/include/ruby/intern.h#L888
 /* variable.c */
 VALUE rb_mod_name(VALUE);
 VALUE rb_class_path(VALUE);
+VALUE rb_class_path_cached(VALUE);
 void rb_set_class_path(VALUE, VALUE, const char*);
 void rb_set_class_path_string(VALUE, VALUE, VALUE);
 VALUE rb_path_to_class(VALUE);
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 44086)
+++ ChangeLog	(revision 44087)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Dec  9 12:25:32 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* variable.c (rb_class_path_cached): returns cached class path
+	  only, without searching and allocating new class path string.
+
 Mon Dec  9 11:14:26 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* ext/date/date_parse.c (parse_time): unset case-insensitive flag
Index: variable.c
===================================================================
--- variable.c	(revision 44086)
+++ variable.c	(revision 44087)
@@ -277,6 +277,18 @@ rb_class_path_no_cache(VALUE klass) https://github.com/ruby/ruby/blob/trunk/variable.c#L277
     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)
 {

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]