File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ use std::arch::x86::*;
1111use std:: arch:: x86_64:: * ;
1212use std:: mem;
1313
14- /// Rolling hash for the simple Rabin-Karp implementation. As a hashing function, the XOR of all the
14+ /// Rolling hash for the simple Rabin-Karp implementation. As a hashing function, the sum of all the
1515/// bytes is computed.
1616#[ derive( Clone , Copy , Default , PartialEq ) ]
1717struct ScalarHash ( usize ) ;
@@ -29,12 +29,12 @@ impl From<&[u8]> for ScalarHash {
2929impl ScalarHash {
3030 #[ inline]
3131 fn push ( & mut self , b : u8 ) {
32- self . 0 ^= usize :: from ( b ) ;
32+ self . 0 = self . 0 . wrapping_add ( b . into ( ) ) ;
3333 }
3434
3535 #[ inline]
3636 fn pop ( & mut self , b : u8 ) {
37- self . 0 ^= usize :: from ( b ) ;
37+ self . 0 = self . 0 . wrapping_sub ( b . into ( ) ) ;
3838 }
3939}
4040
You can’t perform that action at this time.
0 commit comments