| 1 |
|
| #include <stdint.h> |
| 2 |
|
| #include "EXTERN.h" |
| 3 |
|
| #include "perl.h" |
| 4 |
|
| #include "XSUB.h" |
| 5 |
|
| |
| 6 |
|
| #include "ppport.h" |
| 7 |
|
| |
| 8 |
|
| #include "const-c.inc" |
| 9 |
|
| |
| 10 |
|
| /* Bob Jenkin's one at a time hash, has good avalanche behavior */ |
| 11 |
4 |
| unsigned oat ( SV* key ) { |
| 12 |
|
| |
| 13 |
|
| /* Perl Stuff */ |
| 14 |
4 |
| int len = 0; |
| 15 |
4 |
| unsigned char* p = SvPV( key, len ); |
| 16 |
|
| /* End Perl Stuff */ |
| 17 |
|
| |
| 18 |
|
| /* unsigned char *p = str; */ |
| 19 |
4 |
| uint32_t h = 0; |
| 20 |
|
| int i; |
| 21 |
|
| |
| 22 |
20 |
▶ | for ( i = 0; i < len; i++ ) { |
Branch: 1 branch
| Branch | True | False | Total |
| for ( i = 0; i < len; i++ ) { |
16 |
4 |
20 |
|
| 23 |
16 |
| h += p[i]; |
| 24 |
16 |
| h += ( h << 10 ); |
| 25 |
16 |
| h ^= ( h >> 6 ); |
| 26 |
|
| } |
| 27 |
|
| |
| 28 |
4 |
| h += ( h << 3 ); |
| 29 |
4 |
| h ^= ( h >> 11 ); |
| 30 |
4 |
| h += ( h << 15 ); |
| 31 |
|
| |
| 32 |
4 |
| return h; |
| 33 |
|
| } |
| 34 |
|
| |
| 35 |
|
| MODULE = Digest::OAT PACKAGE = Digest::OAT |
| 36 |
|
| |
| 37 |
|
| INCLUDE: const-xs.inc |
| 38 |
|
| |
| 39 |
|
| U32 |
| 40 |
|
| oat (key) |
| 41 |
|
| SV * key |