summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-20 04:02:42 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-20 04:02:42 +0000
commite77a0b7b246b4f0fcb751d6897b7c9ba0c277d55 (patch)
treed03fdf183420b7c4aed212617794a40a1d038847
parent2ad3120ea66689a67222d119a46e677d7cd80b4e (diff)
* string.c (hash): fixed the tail bytes handling in the aligned
access case. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--string.c14
2 files changed, 15 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 63b62fc16ca..ebb317db672 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Jan 20 13:03:50 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * string.c (hash): fixed the tail bytes handling in the aligned
+ access case.
+
Tue Jan 20 09:26:05 2009 NAKAMURA Usaku <usa@ruby-lang.org>
* ext/nkf/nkf-utf8/nkf.c (nkf_buf_push): maybe a bug.
diff --git a/string.c b/string.c
index 1764d69c8ae..fe85148d84b 100644
--- a/string.c
+++ b/string.c
@@ -1874,11 +1874,13 @@ rb_str_concat(VALUE str1, VALUE str2)
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 @@ hash(const unsigned char * data, int len, unsigned int h)
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 @@ hash(const unsigned char * data, int len, unsigned int h)
}
t = 0;
- switch(len) {
+ switch (len) {
#ifdef WORDS_BIGENDIAN
case 3:
t |= data[2] << CHAR_BIT;
@@ -2033,6 +2038,7 @@ hash(const unsigned char * data, int len, unsigned int h)
#if MURMUR == 1
h = murmur_step(h, t);
#elif MURMUR == 2
+ skip_tail:
h ^= t;
h *= MurmurMagic;
#endif