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

ruby-changes:10140

From: nobu <ko1@a...>
Date: Tue, 20 Jan 2009 13:03:03 +0900 (JST)
Subject: [ruby-changes:10140] Ruby:r21684 (trunk): * string.c (hash): fixed the tail bytes handling in the aligned

nobu	2009-01-20 13:02:42 +0900 (Tue, 20 Jan 2009)

  New Revision: 21684

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

  Log:
    * string.c (hash): fixed the tail bytes handling in the aligned
      access case.

  Modified files:
    trunk/ChangeLog
    trunk/string.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 21683)
+++ ChangeLog	(revision 21684)
@@ -1,3 +1,8 @@
+Tue Jan 20 13:03:50 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* string.c (hash): fixed the tail bytes handling in the aligned
+	  access case.
+
 Tue Jan 20 09:26:05 2009  NAKAMURA Usaku  <usa@r...>
 
 	* ext/nkf/nkf-utf8/nkf.c (nkf_buf_push): maybe a bug.
Index: string.c
===================================================================
--- string.c	(revision 21683)
+++ string.c	(revision 21684)
@@ -1874,11 +1874,13 @@
     return rb_str_append(str1, str2);
 }
 
-#if defined __i386__ || defined _M_IX86
-#define UNALIGNED_WORD_ACCESS 1
+#ifndef UNALIGNED_WORD_ACCESS
+# if defined __i386__ || defined _M_IX86
+#   define UNALIGNED_WORD_ACCESS 1
+# endif
 #endif
 #ifndef UNALIGNED_WORD_ACCESS
-#define UNALIGNED_WORD_ACCESS 0
+# define UNALIGNED_WORD_ACCESS 0
 #endif
 
 /* MurmurHash described in http://murmurhash.googlepages.com/ */
@@ -1998,6 +2000,9 @@
 	    t = (t >> sr) | (d << sl);
 #endif
 
+#if MURMUR == 2
+	    if (len < align) goto skip_tail;
+#endif
 	    h = murmur_step(h, t);
 	    data += pack;
 	    len -= pack;
@@ -2014,7 +2019,7 @@
     }
 
     t = 0;
-    switch(len) {
+    switch (len) {
 #ifdef WORDS_BIGENDIAN
       case 3:
 	t |= data[2] << CHAR_BIT;
@@ -2033,6 +2038,7 @@
 #if MURMUR == 1
 	h = murmur_step(h, t);
 #elif MURMUR == 2
+      skip_tail:
 	h ^= t;
 	h *= MurmurMagic;
 #endif

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

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