OAT.xs

filter: Statementstmt 100% 12 / 12 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 100% 14 / 14 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« const-xs.inc ↑ Summary blib/lib/Digest/OAT.pm »
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
BranchTrueFalseTotal
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
« const-xs.inc ↑ Summary blib/lib/Digest/OAT.pm »