[#19457] equality between "a" and Exception.new("a") — Tanaka Akira <akr@...17n.org>

ふと気がついたのですが、

39 messages 2003/02/02
[#19460] Re: equality between "a" and Exception.new("a") — matz@... (Yukihiro Matsumoto) 2003/02/03

まつもと ゆきひろです

[#19473] Re: equality between "a" and Exception.new("a") — Tanaka Akira <akr@...17n.org> 2003/02/04

In article <1044245817.592933.31973.nullmailer@picachu.netlab.jp>,

[#19474] Re: equality between "a" and Exception.new("a") — matz@... (Yukihiro Matsumoto) 2003/02/04

まつもと ゆきひろです

[#19475] Re: equality between "a" and Exception.new("a") — Tanaka Akira <akr@...17n.org> 2003/02/04

In article <1044329220.257740.28127.nullmailer@picachu.netlab.jp>,

[#19476] Re: equality between "a" and Exception.new("a") — matz@... (Yukihiro Matsumoto) 2003/02/04

まつもと ゆきひろです

[#19477] Re: equality between "a" and Exception.new("a") — Tanaka Akira <akr@...17n.org> 2003/02/04

In article <1044331431.138035.28173.nullmailer@picachu.netlab.jp>,

[#19478] Re: equality between "a" and Exception.new("a") — matz@... (Yukihiro Matsumoto) 2003/02/04

まつもと ゆきひろです

[#19479] Re: equality between "a" and Exception.new("a") — Tanaka Akira <akr@...17n.org> 2003/02/04

In article <1044332948.099873.28206.nullmailer@picachu.netlab.jp>,

[#19482] Re: equality between "a" and Exception.new("a") — matz@... (Yukihiro Matsumoto) 2003/02/04

まつもと ゆきひろです

[#19486] Re: equality between "a" and Exception.new("a") — Tanaka Akira <akr@...17n.org> 2003/02/04

In article <1044338964.502066.28474.nullmailer@picachu.netlab.jp>,

[#19491] Re: equality between "a" and Exception.new("a") — matz@... (Yukihiro Matsumoto) 2003/02/04

まつもと ゆきひろです

[#19493] Re: equality between "a" and Exception.new("a") — matz@... (Yukihiro Matsumoto) 2003/02/04

まつもと ゆきひろです

[#19556] compare between String and Exception — Tanaka Akira <akr@...17n.org> 2003/02/12

さらに気が付いたのですが、

[#19514] [Oniguruma] Version 1.7.1 — "K.Kosako" <kosako@...>

ftp.ruby-lang.orgに、onigd20030207.tar.gzを置きました。

19 messages 2003/02/07

[#19548] [PATCH] file.c for (PR#389) and (PR#390) — nobu.nakada@...

なかだです。

20 messages 2003/02/11
[#19572] Re: [PATCH] file.c for (PR#389) and (PR#390) — pegacorn@... 2003/02/14

From: nobu.nakada@nifty.ne.jp

[#19648] Re: SEGV at search_method in eval.c (PR#400) — nobu.nakada@...

なかだです。

13 messages 2003/02/24

[ruby-dev:19458] Re: Karp-Rabin (Re: new keyword once)

From: nobu.nakada@...
Date: 2003-02-03 03:09:07 UTC
List: ruby-dev #19458
なかだです。

At Sun, 2 Feb 2003 01:40:48 +0900,
Yukihiro Matsumoto wrote:
> 実際、簡単なベンチマークでは検索文字列が短く、検索する文字列
> があまり長くないケースではKRが一番良い成績を残すことが多いよ
> うです(BM, Quick, Shift-Or, KRで比較しました)。ま、実は似た
> りよったりなんですが。

乗算よりもシフトのほうが速そうな気がするんですが、どうなんでしょ
うか。あまり変わらないかも。


Index: string.c
===================================================================
RCS file: /cvs/ruby/src/ruby/string.c,v
retrieving revision 1.136
diff -u -2 -p -r1.136 string.c
--- string.c	31 Jan 2003 06:48:54 -0000	1.136
+++ string.c	3 Feb 2003 02:53:46 -0000
@@ -841,5 +841,6 @@ rb_str_index(str, sub, offset)
     char *s, *e, *p;
     long len;
-    int d, hx, hy, i;
+    int d, i;
+    unsigned long hx, hy;
 
     if (offset < 0) {
@@ -860,13 +861,13 @@ rb_str_index(str, sub, offset)
     */
 
-#define KR_REHASH(a, b, h) ((((h) - (a)*d) << 1) + (b))
+#define KR_REHASH(a, b, h) ((((h) ^ ((a)<<d)) << 1) ^ (b))
 
     /* Preprocessing */
     /* computes d = 2^(m-1) with
        the left-shift operator */
-    for (d = i = 1; i < len; ++i)
-	d = (d<<1);
+    d = sizeof(hx) * CHAR_BIT - 1;
+    if (d > len) d = len;
 
-    for (hy = hx = i = 0; i < len; ++i) {
+    for (hy = hx = i = 0; i < d; ++i) {
 	hx = ((hx<<1) + p[i]);
 	hy = ((hy<<1) + s[i]);


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

In This Thread