blib/lib/Digest/FNV.pm

filter: Statementstmt 83.3% 55 / 66 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 84.6% 11 / 13 Podpod 0.0% 0 / 3 totaltotal 76.7% 66 / 86 CC 3 SCAR 9.2
CC
3
Cov
79%
AUTOLOAD
8.2
__ANON__
2.0
BEGIN
1.0
CRAP 2.5
↑ Summary const-c.inc »
1 package Digest::FNV;
2  
3 2 ▶use 5.010000;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 require Exporter;
9 2 ▶use AutoLoader;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 #use Data::Dumper;
11  
12 2 our @ISA = qw(Exporter);
13  
14 # Items to export into callers namespace by default. Note: do not export
15 # names by default without a very good reason. Use EXPORT_OK instead.
16 # Do not simply export all your public functions/methods/constants.
17  
18 # This allows declaration use Digest::FNV ':all';
19 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
20 # will save memory.
21 #our %EXPORT_TAGS = ( 'all' => [ qw(
22 # FNV0_32_INIT
23 # FNV1A_64_LOWER
24 # FNV1A_64_UPPER
25 # FNV1_32A_INIT
26 # FNV1_32_INIT
27 # FNV1_64_LOWER
28 # FNV1_64_UPPER
29 #) ] );
30  
31 2 our @EXPORT_OK = ( );
32  
33 2 our @EXPORT = qw( fnv fnv32 fnv32a fnv64 fnv64a );
34 #= qw(
35 # FNV0_32_INIT
36 # FNV1A_64_LOWER
37 # FNV1A_64_UPPER
38 # FNV1_32A_INIT
39 # FNV1_32_INIT
40 # FNV1_64_LOWER
41 # FNV1_64_UPPER
42 #);
43  
44 2 our $VERSION = '2.00';
45  
46 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=3 SCAR=21.1
47 # This AUTOLOAD is used to 'autoload' constants from the constant()
48 # XS function.
49  
50 0 my $constname;
51 0 our $AUTOLOAD;
52 0 ($constname = $AUTOLOAD) =~ s/.*:://;
53 0 ▶ croak "&Digest::FNV::constant not defined" if $constname eq 'constant';
Branch: 1 branch
BranchTrueFalseTotal
if $constname eq "constant" 0 0 0
54 0 my ($error, $val) = constant($constname);
55 0 ▶ if ($error) { croak $error; }
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 0 0 0
56 {
57 0 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.2
58 # Fixed between 5.005_53 and 5.005_61
59 #XXX if ($] >= 5.00561) {
60 #XXX *$AUTOLOAD = sub () { $val };
61 #XXX }
62 #XXX else {
63 0 ▶ *$AUTOLOAD = sub { $val };
Subroutine __ANON__: not called CC=1 SCAR=6.9
64 #XXX }
65 }
66 0 goto &$AUTOLOAD;
67 }
68  
69 2 require XSLoader;
70 2 XSLoader::load('Digest::FNV', $VERSION);
71  
72 # Preloaded methods go here.
73  
74 4 ▶sub fnv {
Subroutine fnv: called CC=1 SCAR=0.0
Pod undocumented
75 4 my ($string) = @_;
76 4 return fnv32($string);
77 }
78  
79 4 ▶sub fnv64 {
Subroutine fnv64: called CC=1 SCAR=0.0
Pod undocumented
80 4 my ($string) = @_;
81 4 my @fnv_hash = fnv64_t($string);
82 #print Dumper(\@fnv_hash); print "\n";
83  
84 4 my %hash = ();
85 # This is a little test for what kind of system we're on, 32 or 64
86 4 if ( (1 << 32) != 4294967296) {
87 $hash{'bits'} = 32;
88 }
89 else {
90 4 $hash{'bits'} = 64;
91 }
92  
93 4 $hash{'longlong'} = ($fnv_hash[1] << 32) | $fnv_hash[0] + 0;
94 4 $hash{'lower'} = $fnv_hash[0];
95 4 $hash{'upper'} = $fnv_hash[1];
96  
97 2 ▶ use bigint;
Subroutine BEGIN: called CC=1 SCAR=0.0
98 4 my $retval = ($fnv_hash[1] << 32) | $fnv_hash[0];
99 4 $hash{'bigint'} = $retval; # very likely a string
100  
101 4 return \%hash;
102 }
103  
104 4 ▶sub fnv64a {
Subroutine fnv64a: called CC=1 SCAR=0.0
Pod undocumented
105 4 my ($string) = @_;
106 4 my @fnv_hash = fnv64a_t($string);
107 #print Dumper(\@fnv_hash); print "\n";
108  
109 4 my %hash = ();
110 # This is a little test for what kind of system we're on, 32 or 64
111 4 if ( (1 << 32) != 4294967296) {
112 $hash{'bits'} = 32;
113 }
114 else {
115 4 $hash{'bits'} = 64;
116 }
117  
118 4 $hash{'longlong'} = ($fnv_hash[1] << 32) | $fnv_hash[0] + 0;
119 4 $hash{'lower'} = $fnv_hash[0];
120 4 $hash{'upper'} = $fnv_hash[1];
121  
122 2 ▶ use bigint;
Subroutine BEGIN: called CC=1 SCAR=0.0
123 4 my $retval = ($fnv_hash[1] << 32) | $fnv_hash[0];
124 4 $hash{'bigint'} = $retval; # very likely a string
125  
126 4 return \%hash;
127 }
128  
129 # Autoload methods go after =cut, and are processed by the autosplit program.
130  
131 2 1;
132 __END__
↑ Summary const-c.inc »