[#40528] [Feature #2833] 絵文字エンコーディングの提案 — Kenta Murata <redmine@...>

Feature #2833: 絵文字エンコーディングの提案

32 messages 2010/03/02
[#40530] Re: [Feature #2833] 絵文字エンコーディングの提案 — Yukihiro Matsumoto <matz@...> 2010/03/02

まつもと ゆきひろです

[#40597] Re: [ruby-list:46898] 重複組合せは組込みにならないのでしょうか? — "KISHIMOTO, Makoto" <ksmakoto@...4u.or.jp>

きしもとです

17 messages 2010/03/12
[#40598] Re: [ruby-list:46898] 重複組合せは組込みにならないのでしょうか? — Yukihiro Matsumoto <matz@...> 2010/03/12

まつもと ゆきひろです

[#40601] Re: [ruby-list:46898] 重複組合せは組込みにならないのでしょうか? — Yusuke ENDOH <mame@...> 2010/03/12

遠藤です。

[#40608] Re: 組込みの重複順列・重複組合せ — "KISHIMOTO, Makoto" <ksmakoto@...4u.or.jp> 2010/03/13

> 同様に、repeated_permutation/combination のデフォルト引数にも反対

[#40610] Re: 組込みの重複順列・重複組合せ — Yukihiro Matsumoto <matz@...> 2010/03/13

まつもと ゆきひろです

[#40641] [Bug #2965] method `===' called on hidden T_STRING object (NotImplementedError) — Kenta Murata <redmine@...>

Bug #2965: method `===' called on hidden T_STRING object (NotImplementedError)

12 messages 2010/03/15

[#40649] [Feature #2968] 数値の正負を返すメソッド — Yui NARUSE <redmine@...>

Feature #2968: 数値の正負を返すメソッド

17 messages 2010/03/15

[#40650] [Feature #2969] String#to_f が -h.hhh±pd を解釈できるように — Yui NARUSE <redmine@...>

Feature #2969: String#to_f が -h.hhh±pd を解釈できるように

38 messages 2010/03/15
[#40728] Re: [Feature #2969] String#to_f が -h.hhh±pd を解釈できるように — Tadayoshi Funaba <tadf@...> 2010/03/22

質問ですが、この形式は入力だけでなく、なんらかの方法で出力でも利用でき

[#40732] Re: [Feature #2969] String#to_f が -h.hhh±pd を解釈できるように — "NARUSE, Yui" <naruse@...> 2010/03/22

成瀬です。

[#40736] Re: [Feature #2969] String#to_f が -h.hhh±pd を解釈できるように — Tadayoshi Funaba <tadf@...> 2010/03/23

> String#to_f は従来から指数表記を許していたので、

[#40738] Re: [Feature #2969] String#to_f が -h.hhh±pd を解釈できるように — "NARUSE, Yui" <naruse@...> 2010/03/23

成瀬です。

[#40745] Re: [Feature #2969] String#to_f が -h.hhh±pd を解釈できるように — Tadayoshi Funaba <tadf@...> 2010/03/24

> to_i がデフォルトで prefix を見ないのは、0377 のような、

[#40747] Re: [Feature #2969] String#to_f が -h.hhh±pd を解釈できるように — "NARUSE, Yui" <naruse@...> 2010/03/24

成瀬です。

[#40749] Re: [Feature #2969] String#to_f が -h.hhh±pd を解釈できるように — Tadayoshi Funaba <tadf@...> 2010/03/24

> 先のパッチの対象関数が ruby_strtod である通り、

[#40759] Re: [Feature #2969] String#to_f が -h.hhh±pd を解釈できるように — "NARUSE, Yui" <naruse@...> 2010/03/25

成瀬です。

[#40762] Re: [Feature #2969] String#to_f が -h.hhh±pd を解釈できるように — Tadayoshi Funaba <tadf@...> 2010/03/25

> strtod(3) の解釈対象に含まれていない 2 進や 8 進を否定することが、

[#40763] Re: [Feature #2969] String#to_f が -h.hhh±pd を解釈できるように — "NARUSE, Yui" <naruse@...> 2010/03/25

(2010/03/26 3:05), Tadayoshi Funaba wrote:

[#40764] Re: [Feature #2969] String#to_f が -h.hhh±pd を解釈できるように — Tadayoshi Funaba <tadf@...> 2010/03/25

> なぜ同じなのでしょう。

[#40782] Re: [Feature #2969] String#to_f が -h.hhh±pd を解釈できるように — "NARUSE, Yui" <naruse@...> 2010/03/26

(2010/03/26 4:02), Tadayoshi Funaba wrote:

[#40786] Re: [Feature #2969] String#to_f が -h.hhh±pd を解釈できるように — KOSAKI Motohiro <kosaki.motohiro@...> 2010/03/27

>> strtod(3) を参考にしたり、影響されたりすることは普通にあるとは思います

[#40788] Re: [Feature #2969] String#to_f が -h.hhh±pd を解釈できるように — "NARUSE, Yui" <naruse@...> 2010/03/27

(2010/03/27 18:19), KOSAKI Motohiro wrote:

[#40695] keiju, please check tickets assigned to you — Yusuke ENDOH <mame@...>

いしつかさん

15 messages 2010/03/18

[#40779] [Feature #3018] UNINITIALIZED_VAR() マクロの導入 — Motohiro KOSAKI <redmine@...>

Feature #3018: UNINITIALIZED_VAR() マクロの導入

12 messages 2010/03/26

[#40805] Improvement of Fiber switching cost with system dependent way — SASADA Koichi <ko1@...>

 ささだです.

10 messages 2010/03/28

[ruby-dev:40603] 1.9のrequireが遅い

From: Shugo Maeda <shugo@...>
Date: 2010-03-12 17:38:01 UTC
List: ruby-dev #40603
前田です。

またYehuda Katz情報なのですが、Ruby 1.9で、$:の要素が多いとrequireが遅いようです。

defiant:build$ cat t.rb
1000.times {
  $:.push "/opt/ruby/1.8"
}
1000.times do
  require "rational"
end
defiant:build$ time ruby -v t.rb
ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]
ruby -v t.rb  0.07s user 0.08s system 90% cpu 0.164 total
defiant:build$ time ruby-trunk -v t.rb
ruby 1.9.2dev (2010-03-10 trunk 26866) [i686-linux]
lib/rational.rb is deprecated
ruby-trunk -v t.rb  3.51s user 1.20s system 99% cpu 4.734 total

この例は極端ですが、Gemパッケージがたくさん入っている状態でRailsを
動かしたりすると、結構影響が大きいそうです。

どうも、rb_get_expanded_load_path()が何度も呼ばれるせいでこんなに
遅いようなのですが、$:の中身がすべて絶対パスの時は、expand_pathを
呼ばずにそのまま$:の値を使うようにしてはどうでしょうか。

添付のパッチでかなり早くなりました。

defiant:build$ time ./ruby-trunk -v t.rb
ruby 1.9.2dev (2010-03-11 trunk 26868) [i686-linux]
lib/rational.rb is deprecated
./ruby-trunk -v t.rb  0.28s user 0.01s system 99% cpu 0.293 total

$:に相対パスが入っているとだめですが、幸い1.9では$:から.が削除されて
いますし、require_relativeも使えるので$:に相対パスを入れたいというニーズ
もあまりないんじゃないかと思っています。

-- 
Shugo Maeda

Attachments (1)

rb_get_expanded_load_path.diff (3.02 KB, text/x-diff)
diff --git a/file.c b/file.c
index 50516ad..47f864b 100644
--- a/file.c
+++ b/file.c
@@ -2687,8 +2687,6 @@ ntfs_tail(const char *path)
     (void)(extenc || (extenc = rb_default_external_encoding())),\
     rb_enc_associate(result, extenc))
 
-static int is_absolute_path(const char*);
-
 VALUE
 rb_home_dir(const char *user, VALUE result)
 {
@@ -2802,7 +2800,7 @@ file_expand_path(VALUE fname, VALUE dname, int abs_mode, VALUE result)
 	}
     }
 #endif
-    else if (!is_absolute_path(s)) {
+    else if (!rb_is_absolute_path(s)) {
 	if (!NIL_P(dname)) {
 	    file_expand_path(dname, Qnil, abs_mode, result);
 	    BUFINIT();
@@ -4698,8 +4696,8 @@ rb_file_const(const char *name, VALUE value)
     rb_define_const(rb_mFConst, name, value);
 }
 
-static int
-is_absolute_path(const char *path)
+int
+rb_is_absolute_path(const char *path)
 {
 #ifdef DOSISH_DRIVE_LETTER
     if (has_drive_letter(path) && isdirsep(path[2])) return 1;
@@ -4729,7 +4727,7 @@ path_check_0(VALUE path, int execpath)
     const char *p0 = StringValueCStr(path);
     char *p = 0, *s;
 
-    if (!is_absolute_path(p0)) {
+    if (!rb_is_absolute_path(p0)) {
 	char *buf = my_getcwd();
 	VALUE newpath;
 
@@ -4866,7 +4864,7 @@ rb_find_file_ext_safe(VALUE *filep, const char *const *ext, int safe_level)
 	expanded = 1;
     }
 
-    if (expanded || is_absolute_path(f) || is_explicit_relative(f)) {
+    if (expanded || rb_is_absolute_path(f) || is_explicit_relative(f)) {
 	if (safe_level >= 1 && !fpath_check(fname)) {
 	    rb_raise(rb_eSecurityError, "loading from unsafe path %s", f);
 	}
@@ -4937,7 +4935,7 @@ rb_find_file_safe(VALUE path, int safe_level)
 	expanded = 1;
     }
 
-    if (expanded || is_absolute_path(f) || is_explicit_relative(f)) {
+    if (expanded || rb_is_absolute_path(f) || is_explicit_relative(f)) {
 	if (safe_level >= 1 && !fpath_check(path)) {
 	    rb_raise(rb_eSecurityError, "loading from unsafe path %s", f);
 	}
diff --git a/include/ruby/intern.h b/include/ruby/intern.h
index ebbdd71..f9ee9dc 100644
--- a/include/ruby/intern.h
+++ b/include/ruby/intern.h
@@ -366,6 +366,7 @@ char *rb_path_skip_prefix(const char *);
 char *rb_path_last_separator(const char *);
 char *rb_path_end(const char *);
 VALUE rb_file_directory_p(VALUE,VALUE);
+int rb_is_absolute_path(const char *);
 /* gc.c */
 void ruby_set_stack_size(size_t);
 NORETURN(void rb_memerror(void));
diff --git a/load.c b/load.c
index 7551b6b..75c0c19 100644
--- a/load.c
+++ b/load.c
@@ -37,10 +37,19 @@ VALUE
 rb_get_expanded_load_path(void)
 {
     VALUE load_path = rb_get_load_path();
-    VALUE ary = rb_ary_new2(RARRAY_LEN(load_path));
+    VALUE ary;
     long i;
 
     for (i = 0; i < RARRAY_LEN(load_path); ++i) {
+	char *s = StringValuePtr(RARRAY_PTR(load_path)[i]);
+	if (!rb_is_absolute_path(s))
+	    goto relative_path_found;
+    }
+    return load_path;
+
+  relative_path_found:
+    ary = rb_ary_new2(RARRAY_LEN(load_path));
+    for (i = 0; i < RARRAY_LEN(load_path); ++i) {
 	VALUE path = rb_file_expand_path(RARRAY_PTR(load_path)[i], Qnil);
 	rb_str_freeze(path);
 	rb_ary_push(ary, path);

In This Thread

Prev Next