Skip to content

Commit ff55382

Browse files
committed
approach 6
1 parent 69ec4b7 commit ff55382

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

include/boost/json/detail/digest.hpp

+14-3
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,20 @@ digest(
4343
hash = (batch ^ hash) * prime;
4444
}
4545

46-
std::uint32_t batch = 0;
47-
std::memcpy(&batch, s, n);
48-
hash = (batch ^ hash) * prime;
46+
switch(n)
47+
{
48+
case 3:
49+
hash = (*s++ ^ hash) * prime;
50+
// fall through
51+
case 2:
52+
hash = (*s++ ^ hash) * prime;
53+
// fall through
54+
case 1:
55+
hash = (*s++ ^ hash) * prime;
56+
// fall through
57+
default:
58+
break;
59+
}
4960

5061
return hash;
5162
}

0 commit comments

Comments
 (0)