[#32945] Shift_JIS variants and UTF-16 support — "U.Nakamura" <usa@...>

こんにちは、なかむら(う)です。

22 messages 2008/01/07
[#32953] Re: Shift_JIS variants and UTF-16 support — Martin Duerst <duerst@...> 2008/01/07

中村さん、こんにちは。

[#32955] Re: Shift_JIS variants and UTF-16 support — Yukihiro Matsumoto <matz@...> 2008/01/07

まつもと ゆきひろです

[#32959] Re: Shift_JIS variants and UTF-16 support — "NARUSE, Yui" <naruse@...> 2008/01/07

成瀬です。

[#32960] Re: Shift_JIS variants and UTF-16 support — Yukihiro Matsumoto <matz@...> 2008/01/07

まつもと ゆきひろです

[#32992] ASCII is alias of US-ASCII; replica of dummy encoding is not a dummy — "NARUSE, Yui" <naruse@...>

成瀬です。

18 messages 2008/01/08
[#32994] Re: ASCII is alias of US-ASCII; replica of dummy encoding is not a dummy — Yukihiro Matsumoto <matz@...> 2008/01/09

まつもと ゆきひろです

[#32995] Re: ASCII is alias of US-ASCII; replica of dummy encoding is not a dummy — Martin Duerst <duerst@...> 2008/01/09

At 18:13 08/01/09, Yukihiro Matsumoto wrote:

[#33011] Re: ASCII is alias of US-ASCII; replica of dummy encoding is not a dummy — "NARUSE, Yui" <naruse@...> 2008/01/11

成瀬です。

[#33012] Re: ASCII is alias of US-ASCII; replica of dummy encoding is not a dummy — Yukihiro Matsumoto <matz@...> 2008/01/11

まつもと ゆきひろです

[#33014] Re: ASCII is alias of US-ASCII; replica of dummy encoding is not a dummy — "NARUSE, Yui" <naruse@...> 2008/01/11

成瀬です。

[#33015] Re: ASCII is alias of US-ASCII; replica of dummy encoding is not a dummy — Yukihiro Matsumoto <matz@...> 2008/01/11

まつもと ゆきひろです

[#33239] Re: [ruby-cvs:22386] Ruby:r15149 (trunk): * string.c (rb_str_each_char): move forward. — Tanaka Akira <akr@...>

In article <200801210259.m0L2x3CW017171@ci.ruby-lang.org>,

11 messages 2008/01/21
[#33240] Re: [ruby-cvs:22386] Ruby:r15149 (trunk): * string.c (rb_str_each_char): move forward. — Nobuyoshi Nakada <nobu@...> 2008/01/21

なかだです。

[#33303] Time#strftimeのエンコーディング — rubikitch@...

るびきちです。

13 messages 2008/01/23
[#33305] Re: Time#strftimeのエンコーディング — Yukihiro Matsumoto <matz@...> 2008/01/23

まつもと ゆきひろです

[#33368] summary of script encoding — "U.Nakamura" <usa@...>

こんにちは、なかむら(う)です。

22 messages 2008/01/25
[#33375] Re: summary of script encoding — Yukihiro Matsumoto <matz@...> 2008/01/25

まつもと ゆきひろです

[#33376] Re: summary of script encoding — "U.Nakamura" <usa@...> 2008/01/25

こんにちは、なかむら(う)です。

[#33387] HashからStructを作る — rubikitch@...

るびきちです。

19 messages 2008/01/25
[#33455] Re: HashからStructを作る — Yukihiro Matsumoto <matz@...> 2008/01/28

まつもと ゆきひろです

[#33505] Re: HashからStructを作る — rubikitch@... 2008/01/29

From: Yukihiro Matsumoto <matz@ruby-lang.org>

[#33507] Re: HashからStructを作る — Yukihiro Matsumoto <matz@...> 2008/01/29

まつもと ゆきひろです

[#33508] Re: HashからStructを作る — rubikitch@... 2008/01/29

From: Yukihiro Matsumoto <matz@ruby-lang.org>

[#33433] Win32OLE: set encoding to OLE string — "U.Nakamura" <usa@...>

こんにちは、なかむら(う)です。

16 messages 2008/01/28

[#33461] Failed to make ruby-1.8.6-p111 on MacOSX 10.5(Leopard) — MORITA Hideyuki <h-morita@...>

=1B$B?9ED$H?=3D$7$^$9!#=1B(B

19 messages 2008/01/28
[#33473] Re: Failed to make ruby-1.8.6-p111 on MacOSX 10.5(Leopard) — Nobuyoshi Nakada <nobu@...> 2008/01/28

なかだです。

[#33503] Re: Failed to make ruby-1.8.6-p111 on MacOSX 10.5(Leopard) — MORITA Hideyuki <h-morita@...> 2008/01/29

森田です。

[#33514] Re: Failed to make ruby-1.8.6-p111 on MacOSX 10.5(Leopard) — Nobuyoshi Nakada <nobu@...> 2008/01/29

なかだです。

[#33518] Re: Failed to make ruby-1.8.6-p111 on MacOSX 10.5(Leopard) — MORITA Hideyuki <h-morita@...> 2008/01/30

森田です。

[#33545] Re: Failed to make ruby-1.8.6-p111 on MacOSX 10.5(Leopard) — Ryutaro Amano <wn9r-amn@...> 2008/01/31

天野竜太郎と申します。

[#33546] Re: Failed to make ruby-1.8.6-p111 on MacOSX 10.5(Leopard) — MORITA Hideyuki <h-morita@...> 2008/01/31

森田です。

[#33547] Re: Failed to make ruby-1.8.6-p111 on MacOSX 10.5(Leopard) — Ryutaro Amano <wn9r-amn@...> 2008/01/31

天野です。

[#33551] Re: Failed to make ruby-1.8.6-p111 on MacOSX 10.5(Leopard) — MORITA Hideyuki <h-morita@...> 2008/01/31

森田です。

[#33488] 現在の script encoding の値を得る方法は? — Hidetoshi NAGAI <nagai@...>

永井@知能.九工大です.

20 messages 2008/01/29
[#33491] Re: 現在の script encoding の値を得る方法は? — Yukihiro Matsumoto <matz@...> 2008/01/29

まつもと ゆきひろです

[#33500] Re: 現在の script encoding の値を得る方法は? — Hidetoshi NAGAI <nagai@...> 2008/01/29

永井@知能.九工大です.

[#33501] Re: 現在の script encoding の値を得る方法は? — "NARUSE, Yui" <naruse@...> 2008/01/29

成瀬です。

[#33515] Re: 現在の script encoding の値を得る方法は? — Hidetoshi NAGAI <nagai@...> 2008/01/30

永井@知能.九工大です.

[#33516] Re: 現在の script encoding の値を得る方法は? — "NARUSE, Yui" <naruse@...> 2008/01/30

成瀬です。

[#33519] Re: 現在の script encoding の値を得る方法は? — Hidetoshi NAGAI <nagai@...> 2008/01/30

永井@知能.九工大です.

[#33522] Re: 現在の script encoding の値を得る方法は? — "NARUSE, Yui" <naruse@...> 2008/01/30

成瀬です。

[ruby-dev:33277] Re: [ruby-cvs:22386] Ruby:r15149 (trunk): * string.c (rb_str_each_char): move forward.

From: Nobuyoshi Nakada <nobu@...>
Date: 2008-01-22 14:38:18 UTC
List: ruby-dev #33277
なかだです。

At Mon, 21 Jan 2008 21:08:36 +0900,
Yukihiro Matsumoto wrote in [ruby-dev:33255]:
> ||freezeしたコピーを作っておいて、変更の影響を受けないようにすると
> ||いうのを思い付きました。当然のことながら格段に速くなるようです。
> |
> |んじゃ、この線でコミットしてください。
> 
> 他のyieldを呼ぶメソッド(each_lineとかgsubとか)もコピーを作っ
> た方がよいでしょうか。

こんなとこでしょうか。


Index: string.c
===================================================================
--- string.c	(revision 15173)
+++ string.c	(working copy)
@@ -229,5 +229,5 @@ int rb_enc_str_asciionly_p(VALUE str)
 
 static inline void
-str_mod_check(VALUE s, char *p, long len)
+str_mod_check(VALUE s, const char *p, long len)
 {
     if (RSTRING_PTR(s) != p || RSTRING_LEN(s) != len){
@@ -416,4 +416,6 @@ rb_str_new4(VALUE orig)
 }
 
+#define rb_str_shadow(p) (*(volatile VALUE *)(p) = rb_str_new4(*(p)))
+
 VALUE
 rb_str_new5(VALUE obj, const char *ptr, long len)
@@ -4463,10 +4465,8 @@ rb_str_each_line(int argc, VALUE *argv, 
 {
     rb_encoding *enc;
-    VALUE rs;
+    VALUE self = str, rs, line;
     int newline;
-    char *p = RSTRING_PTR(str), *pend = p + RSTRING_LEN(str), *s = p;
-    char *ptr = p;
-    long len = RSTRING_LEN(str), rslen;
-    VALUE line;
+    const char *p, *pend, *s, *ptr, *rsptr;
+    long len, rslen;
     int n;
 
@@ -4480,7 +4480,13 @@ rb_str_each_line(int argc, VALUE *argv, 
 	return str;
     }
-    StringValue(rs);
+
+    rb_str_shadow(&str);
     enc = rb_enc_check(str, rs);
-    if (rs == rb_default_rs) {
+    ptr = s = p = RSTRING_PTR(str);
+    len = RSTRING_LEN(str);
+    pend = p + len;
+
+    StringValue(rs);
+    if (rs == rb_default_rs || rb_str_shadow(&rs) == rb_default_rs) {
 	while (p < pend) {
 	    n = rb_enc_mbclen(p, pend, enc);
@@ -4490,5 +4496,4 @@ rb_str_each_line(int argc, VALUE *argv, 
 		rb_enc_copy(line, str);
 		rb_yield(line);
-		str_mod_check(str, ptr, len);
 		s = p + n;
 	    }
@@ -4498,4 +4503,5 @@ rb_str_each_line(int argc, VALUE *argv, 
     }
 
+    rsptr = RSTRING_PTR(rs);
     rslen = RSTRING_LEN(rs);
     if (rslen == 0) {
@@ -4503,5 +4509,5 @@ rb_str_each_line(int argc, VALUE *argv, 
     }
     else {
-	newline = rb_enc_codepoint(RSTRING_PTR(rs), RSTRING_END(rs), enc);
+	newline = rb_enc_codepoint(rsptr, rsptr+rslen, enc);
     }
 
@@ -4517,10 +4523,9 @@ rb_str_each_line(int argc, VALUE *argv, 
 	}
 	if (c == newline &&
-	    (rslen <= 1 || memcmp(RSTRING_PTR(rs), p, rslen) == 0)) {
+	    (rslen <= 1 || memcmp(rsptr, p, rslen) == 0)) {
 	    line = rb_str_new5(str, s, p - s + (rslen ? rslen : n));
 	    OBJ_INFECT(line, str);
 	    rb_enc_copy(line, str);
 	    rb_yield(line);
-	    str_mod_check(str, ptr, len);
 	    s = p + (rslen ? rslen : n);
 	}
@@ -4537,5 +4542,5 @@ rb_str_each_line(int argc, VALUE *argv, 
     }
 
-    return str;
+    return self;
 }
 
@@ -4570,11 +4575,16 @@ static VALUE
 rb_str_each_byte(VALUE str)
 {
-    long i;
+    VALUE self = str;
+    const char *ptr;
+    long i, len;
 
     RETURN_ENUMERATOR(str, 0, 0);
-    for (i=0; i<RSTRING_LEN(str); i++) {
-	rb_yield(INT2FIX(RSTRING_PTR(str)[i] & 0xff));
+    rb_str_shadow(&str);
+    ptr = RSTRING_PTR(str);
+    len = RSTRING_LEN(str);
+    for (i=0; i < len; i++) {
+	rb_yield(INT2FIX(ptr[i] & 0xff));
     }
-    return str;
+    return self;
 }
 
@@ -4612,7 +4622,8 @@ rb_str_each_char(VALUE str)
     const char *ptr;
     rb_encoding *enc;
+    VALUE self = str;
 
     RETURN_ENUMERATOR(str, 0, 0);
-    str = rb_str_new4(str);
+    rb_str_shadow(&str);
     ptr = RSTRING_PTR(str);
     len = RSTRING_LEN(str);
@@ -4622,5 +4633,5 @@ rb_str_each_char(VALUE str)
 	rb_yield(rb_str_subseq(str, i, n));
     }
-    return str;
+    return self;
 }
 


-- 
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
    中田 伸悦

In This Thread