blib/lib/Tie/IxHash/FixedSize.pm

filter: Statementstmt 100% 28 / 28 Branchbran 75.0% 6 / 8 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 91.3% 42 / 46 CC 6 SCAR 9.4
CC
6
Cov
92%
TIEHASH
4.2
STORE
3.0
BEGIN
1.0
CRAP 2.6
↑ Summary
1 #
2 # This file is part of Tie-IxHash-FixedSize
3 #
4 # This software is copyright (c) 2018 by Michael Schout.
5 #
6 # This is free software; you can redistribute it and/or modify it under
7 # the same terms as the Perl 5 programming language system itself.
8 #
9  
10 package Tie::IxHash::FixedSize;
11 1 $Tie::IxHash::FixedSize::VERSION = '1.02';
12 # ABSTRACT: Tie::IxHash with a fixed maximum size
13  
14 1 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use parent 'Tie::IxHash';
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 # location of size field in @$self. Tie::IxHash uses 0-3
20 1 ▶use constant SIZE_IX => 4;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 1 ▶sub TIEHASH {
Subroutine TIEHASH: called CC=4 SCAR=14.3
23 1 my $class = shift;
24 1 ▶ my $conf = shift if ref $_[0] eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] eq "HASH" 1 0 1
25  
26 1 ▶ $conf ||= {};
Condition50%1/2
$conf ||= {}
l!l
10
MC/DC0%0/1
$conf ||= {}
$conf
Truth table50%1/2
A
A= $conf
Aresult
11
00
27  
28 1 my $self = $class->SUPER::TIEHASH(@_);
29  
30 1 ▶ if ($conf->{size}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"size"}) 1 0 1
31 1 $self->[SIZE_IX] = $conf->{size};
32 }
33  
34 1 return $self;
35 }
36  
37 7 ▶sub STORE {
Subroutine STORE: called CC=3 SCAR=11.0
38 7 my $self = shift;
39  
40 7 $self->SUPER::STORE(@_);
41  
42 7 ▶ if (my $max_size = $self->[SIZE_IX]) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $max_size = $self->[4]) 4 3 7
43 4 ▶ while ($self->Keys > $max_size) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->Keys > $max_size) 4 4 8
44 4 $self->Shift;
45 }
46 }
47 }
48  
49 1 1;
50  
51 __END__
↑ Summary