Filename | /usr/local/perls/perl-5.26.1/lib/5.26.1/IO/Compress/Base/Common.pm |
Statements | Executed 7113 statements in 12.8ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1262 | 2 | 1 | 2.78ms | 2.78ms | add | U64::
1 | 1 | 1 | 2.39ms | 5.74ms | BEGIN@9 | IO::Compress::Base::Common::
3 | 1 | 1 | 395µs | 575µs | parse | IO::Compress::Base::Parameters::
3 | 1 | 1 | 232µs | 365µs | createSelfTiedObject | IO::Compress::Base::Common::
9 | 2 | 2 | 156µs | 228µs | isaFilehandle | IO::Compress::Base::Common::
15 | 1 | 1 | 125µs | 162µs | _checkType | IO::Compress::Base::Parameters::
6 | 2 | 1 | 109µs | 302µs | whatIsInput | IO::Compress::Base::Common::
6 | 1 | 1 | 102µs | 193µs | whatIs | IO::Compress::Base::Common::
51 | 14 | 2 | 93µs | 93µs | getValue | IO::Compress::Base::Parameters::
3 | 1 | 1 | 63µs | 68µs | isaFilename | IO::Compress::Base::Common::
3 | 1 | 1 | 52µs | 52µs | new | IO::Compress::Base::Parameters::
12 | 1 | 1 | 37µs | 37µs | CORE:match (opcode) | IO::Compress::Base::Common::
3 | 1 | 1 | 29µs | 36µs | setBinModeInput | IO::Compress::Base::Common::
1 | 1 | 1 | 28µs | 33µs | BEGIN@3 | IO::Compress::Base::Common::
6 | 2 | 1 | 26µs | 26µs | new | U64::
3 | 1 | 1 | 22µs | 22µs | setValue | IO::Compress::Base::Parameters::
1 | 1 | 1 | 20µs | 28µs | BEGIN@5 | IO::Compress::Base::Common::
15 | 1 | 1 | 18µs | 18µs | CORE:subst (opcode) | IO::Compress::Base::Common::
1 | 1 | 1 | 17µs | 59µs | BEGIN@49 | IO::Compress::Base::Common::
1 | 1 | 1 | 15µs | 25µs | BEGIN@114 | IO::Compress::Base::Common::
1 | 1 | 1 | 14µs | 63µs | BEGIN@480 | IO::Compress::Base::Common::
1 | 1 | 1 | 14µs | 17µs | BEGIN@520 | IO::Compress::Base::Common::
1 | 1 | 1 | 13µs | 93µs | BEGIN@48 | IO::Compress::Base::Common::
1 | 1 | 1 | 13µs | 29µs | BEGIN@1038 | U64::
1 | 1 | 1 | 12µs | 25µs | BEGIN@4 | IO::Compress::Base::Common::
1 | 1 | 1 | 12µs | 24µs | BEGIN@522 | IO::Compress::Base::Common::
1 | 1 | 1 | 12µs | 56µs | BEGIN@835 | U64::
1 | 1 | 1 | 11µs | 51µs | BEGIN@148 | IO::Compress::Base::Common::
1 | 1 | 1 | 11µs | 116µs | BEGIN@45 | IO::Compress::Base::Common::
1 | 1 | 1 | 11µs | 53µs | BEGIN@46 | IO::Compress::Base::Common::
1 | 1 | 1 | 11µs | 58µs | BEGIN@523 | IO::Compress::Base::Common::
1 | 1 | 1 | 10µs | 42µs | BEGIN@152 | IO::Compress::Base::Common::
1 | 1 | 1 | 10µs | 47µs | BEGIN@836 | U64::
1 | 1 | 1 | 10µs | 49µs | BEGIN@837 | U64::
1 | 1 | 1 | 10µs | 42µs | BEGIN@838 | U64::
1 | 1 | 1 | 9µs | 46µs | BEGIN@150 | IO::Compress::Base::Common::
1 | 1 | 1 | 9µs | 44µs | BEGIN@47 | IO::Compress::Base::Common::
1 | 1 | 1 | 9µs | 46µs | BEGIN@481 | IO::Compress::Base::Common::
1 | 1 | 1 | 9µs | 44µs | BEGIN@483 | IO::Compress::Base::Common::
1 | 1 | 1 | 9µs | 43µs | BEGIN@484 | IO::Compress::Base::Common::
1 | 1 | 1 | 9µs | 40µs | BEGIN@495 | IO::Compress::Base::Common::
1 | 1 | 1 | 9µs | 43µs | BEGIN@50 | IO::Compress::Base::Common::
1 | 1 | 1 | 9µs | 44µs | BEGIN@500 | IO::Compress::Base::Common::
1 | 1 | 1 | 9µs | 41µs | BEGIN@51 | IO::Compress::Base::Common::
1 | 1 | 1 | 9µs | 46µs | BEGIN@7 | IO::Compress::Base::Common::
1 | 1 | 1 | 9µs | 42µs | BEGIN@8 | IO::Compress::Base::Common::
1 | 1 | 1 | 8µs | 45µs | BEGIN@149 | IO::Compress::Base::Common::
1 | 1 | 1 | 8µs | 42µs | BEGIN@482 | IO::Compress::Base::Common::
1 | 1 | 1 | 8µs | 41µs | BEGIN@485 | IO::Compress::Base::Common::
1 | 1 | 1 | 8µs | 41µs | BEGIN@489 | IO::Compress::Base::Common::
1 | 1 | 1 | 8µs | 46µs | BEGIN@490 | IO::Compress::Base::Common::
1 | 1 | 1 | 8µs | 41µs | BEGIN@492 | IO::Compress::Base::Common::
1 | 1 | 1 | 8µs | 45µs | BEGIN@493 | IO::Compress::Base::Common::
1 | 1 | 1 | 8µs | 43µs | BEGIN@494 | IO::Compress::Base::Common::
1 | 1 | 1 | 8µs | 43µs | BEGIN@499 | IO::Compress::Base::Common::
3 | 1 | 1 | 7µs | 7µs | CORE:binmode (opcode) | IO::Compress::Base::Common::
3 | 1 | 1 | 7µs | 7µs | parsed | IO::Compress::Base::Parameters::
0 | 0 | 0 | 0s | 0s | Init | IO::Compress::Base::Common::
0 | 0 | 0 | 0s | 0s | ParseParameters | IO::Compress::Base::Common::
0 | 0 | 0 | 0s | 0s | cleanFileGlobString | IO::Compress::Base::Common::
0 | 0 | 0 | 0s | 0s | getEncoding | IO::Compress::Base::Common::
0 | 0 | 0 | 0s | 0s | hasEncode | IO::Compress::Base::Common::
0 | 0 | 0 | 0s | 0s | isGeMax32 | IO::Compress::Base::Common::
0 | 0 | 0 | 0s | 0s | isaFileGlobString | IO::Compress::Base::Common::
0 | 0 | 0 | 0s | 0s | isaScalar | IO::Compress::Base::Common::
0 | 0 | 0 | 0s | 0s | oneTarget | IO::Compress::Base::Common::
0 | 0 | 0 | 0s | 0s | setBinModeOutput | IO::Compress::Base::Common::
0 | 0 | 0 | 0s | 0s | whatIsOutput | IO::Compress::Base::Common::
0 | 0 | 0 | 0s | 0s | clone | IO::Compress::Base::Parameters::
0 | 0 | 0 | 0s | 0s | getError | IO::Compress::Base::Parameters::
0 | 0 | 0 | 0s | 0s | setError | IO::Compress::Base::Parameters::
0 | 0 | 0 | 0s | 0s | valueOrDefault | IO::Compress::Base::Parameters::
0 | 0 | 0 | 0s | 0s | valueRef | IO::Compress::Base::Parameters::
0 | 0 | 0 | 0s | 0s | wantValue | IO::Compress::Base::Parameters::
0 | 0 | 0 | 0s | 0s | croakError | IO::Compress::Base::Validator::
0 | 0 | 0 | 0s | 0s | new | IO::Compress::Base::Validator::
0 | 0 | 0 | 0s | 0s | saveErrorString | IO::Compress::Base::Validator::
0 | 0 | 0 | 0s | 0s | validateInputArray | IO::Compress::Base::Validator::
0 | 0 | 0 | 0s | 0s | validateInputFilenames | IO::Compress::Base::Validator::
0 | 0 | 0 | 0s | 0s | Value_VV64 | U64::
0 | 0 | 0 | 0s | 0s | add32 | U64::
0 | 0 | 0 | 0s | 0s | clone | U64::
0 | 0 | 0 | 0s | 0s | cmp | U64::
0 | 0 | 0 | 0s | 0s | equal | U64::
0 | 0 | 0 | 0s | 0s | full32 | U64::
0 | 0 | 0 | 0s | 0s | get32bit | U64::
0 | 0 | 0 | 0s | 0s | get64bit | U64::
0 | 0 | 0 | 0s | 0s | getHigh | U64::
0 | 0 | 0 | 0s | 0s | getLow | U64::
0 | 0 | 0 | 0s | 0s | getPacked_V32 | U64::
0 | 0 | 0 | 0s | 0s | getPacked_V64 | U64::
0 | 0 | 0 | 0s | 0s | gt | U64::
0 | 0 | 0 | 0s | 0s | is64bit | U64::
0 | 0 | 0 | 0s | 0s | isAlmost64bit | U64::
0 | 0 | 0 | 0s | 0s | newUnpack_V32 | U64::
0 | 0 | 0 | 0s | 0s | newUnpack_V64 | U64::
0 | 0 | 0 | 0s | 0s | pack_V64 | U64::
0 | 0 | 0 | 0s | 0s | reset | U64::
0 | 0 | 0 | 0s | 0s | subtract | U64::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package IO::Compress::Base::Common; | ||||
2 | |||||
3 | 2 | 37µs | 2 | 38µs | # spent 33µs (28+5) within IO::Compress::Base::Common::BEGIN@3 which was called:
# once (28µs+5µs) by Compress::Zlib::BEGIN@10 at line 3 # spent 33µs making 1 call to IO::Compress::Base::Common::BEGIN@3
# spent 5µs making 1 call to strict::import |
4 | 2 | 32µs | 2 | 38µs | # spent 25µs (12+13) within IO::Compress::Base::Common::BEGIN@4 which was called:
# once (12µs+13µs) by Compress::Zlib::BEGIN@10 at line 4 # spent 25µs making 1 call to IO::Compress::Base::Common::BEGIN@4
# spent 13µs making 1 call to warnings::import |
5 | 2 | 43µs | 2 | 36µs | # spent 28µs (20+8) within IO::Compress::Base::Common::BEGIN@5 which was called:
# once (20µs+8µs) by Compress::Zlib::BEGIN@10 at line 5 # spent 28µs making 1 call to IO::Compress::Base::Common::BEGIN@5
# spent 8µs making 1 call to bytes::import |
6 | |||||
7 | 2 | 36µs | 2 | 83µs | # spent 46µs (9+37) within IO::Compress::Base::Common::BEGIN@7 which was called:
# once (9µs+37µs) by Compress::Zlib::BEGIN@10 at line 7 # spent 46µs making 1 call to IO::Compress::Base::Common::BEGIN@7
# spent 37µs making 1 call to Exporter::import |
8 | 2 | 30µs | 2 | 75µs | # spent 42µs (9+33) within IO::Compress::Base::Common::BEGIN@8 which was called:
# once (9µs+33µs) by Compress::Zlib::BEGIN@10 at line 8 # spent 42µs making 1 call to IO::Compress::Base::Common::BEGIN@8
# spent 33µs making 1 call to Exporter::import |
9 | 2 | 590µs | 1 | 5.74ms | # spent 5.74ms (2.39+3.35) within IO::Compress::Base::Common::BEGIN@9 which was called:
# once (2.39ms+3.35ms) by Compress::Zlib::BEGIN@10 at line 9 # spent 5.74ms making 1 call to IO::Compress::Base::Common::BEGIN@9 |
10 | |||||
11 | 1 | 2µs | require Exporter; | ||
12 | our ($VERSION, @ISA, @EXPORT, %EXPORT_TAGS, $HAS_ENCODE); | ||||
13 | 1 | 11µs | @ISA = qw(Exporter); | ||
14 | 1 | 0s | $VERSION = '2.074'; | ||
15 | |||||
16 | 1 | 3µs | @EXPORT = qw( isaFilehandle isaFilename isaScalar | ||
17 | whatIsInput whatIsOutput | ||||
18 | isaFileGlobString cleanFileGlobString oneTarget | ||||
19 | setBinModeInput setBinModeOutput | ||||
20 | ckInOutParams | ||||
21 | createSelfTiedObject | ||||
22 | |||||
23 | isGeMax32 | ||||
24 | |||||
25 | MAX32 | ||||
26 | |||||
27 | WANT_CODE | ||||
28 | WANT_EXT | ||||
29 | WANT_UNDEF | ||||
30 | WANT_HASH | ||||
31 | |||||
32 | STATUS_OK | ||||
33 | STATUS_ENDSTREAM | ||||
34 | STATUS_EOF | ||||
35 | STATUS_ERROR | ||||
36 | ); | ||||
37 | |||||
38 | 1 | 2µs | %EXPORT_TAGS = ( Status => [qw( STATUS_OK | ||
39 | STATUS_ENDSTREAM | ||||
40 | STATUS_EOF | ||||
41 | STATUS_ERROR | ||||
42 | )]); | ||||
43 | |||||
44 | |||||
45 | 2 | 47µs | 2 | 221µs | # spent 116µs (11+105) within IO::Compress::Base::Common::BEGIN@45 which was called:
# once (11µs+105µs) by Compress::Zlib::BEGIN@10 at line 45 # spent 116µs making 1 call to IO::Compress::Base::Common::BEGIN@45
# spent 105µs making 1 call to constant::import |
46 | 2 | 35µs | 2 | 95µs | # spent 53µs (11+42) within IO::Compress::Base::Common::BEGIN@46 which was called:
# once (11µs+42µs) by Compress::Zlib::BEGIN@10 at line 46 # spent 53µs making 1 call to IO::Compress::Base::Common::BEGIN@46
# spent 42µs making 1 call to constant::import |
47 | 2 | 92µs | 2 | 79µs | # spent 44µs (9+35) within IO::Compress::Base::Common::BEGIN@47 which was called:
# once (9µs+35µs) by Compress::Zlib::BEGIN@10 at line 47 # spent 44µs making 1 call to IO::Compress::Base::Common::BEGIN@47
# spent 35µs making 1 call to constant::import |
48 | 2 | 64µs | 2 | 173µs | # spent 93µs (13+80) within IO::Compress::Base::Common::BEGIN@48 which was called:
# once (13µs+80µs) by Compress::Zlib::BEGIN@10 at line 48 # spent 93µs making 1 call to IO::Compress::Base::Common::BEGIN@48
# spent 80µs making 1 call to constant::import |
49 | 2 | 40µs | 2 | 101µs | # spent 59µs (17+42) within IO::Compress::Base::Common::BEGIN@49 which was called:
# once (17µs+42µs) by Compress::Zlib::BEGIN@10 at line 49 # spent 59µs making 1 call to IO::Compress::Base::Common::BEGIN@49
# spent 42µs making 1 call to constant::import |
50 | 2 | 38µs | 2 | 77µs | # spent 43µs (9+34) within IO::Compress::Base::Common::BEGIN@50 which was called:
# once (9µs+34µs) by Compress::Zlib::BEGIN@10 at line 50 # spent 43µs making 1 call to IO::Compress::Base::Common::BEGIN@50
# spent 34µs making 1 call to constant::import |
51 | 2 | 388µs | 2 | 73µs | # spent 41µs (9+32) within IO::Compress::Base::Common::BEGIN@51 which was called:
# once (9µs+32µs) by Compress::Zlib::BEGIN@10 at line 51 # spent 41µs making 1 call to IO::Compress::Base::Common::BEGIN@51
# spent 32µs making 1 call to constant::import |
52 | |||||
53 | |||||
54 | sub isGeMax32 | ||||
55 | { | ||||
56 | return $_[0] >= MAX32cmp ; | ||||
57 | } | ||||
58 | |||||
59 | sub hasEncode() | ||||
60 | { | ||||
61 | if (! defined $HAS_ENCODE) { | ||||
62 | eval | ||||
63 | { | ||||
64 | require Encode; | ||||
65 | Encode->import(); | ||||
66 | }; | ||||
67 | |||||
68 | $HAS_ENCODE = $@ ? 0 : 1 ; | ||||
69 | } | ||||
70 | |||||
71 | return $HAS_ENCODE; | ||||
72 | } | ||||
73 | |||||
74 | sub getEncoding($$$) | ||||
75 | { | ||||
76 | my $obj = shift; | ||||
77 | my $class = shift ; | ||||
78 | my $want_encoding = shift ; | ||||
79 | |||||
80 | $obj->croakError("$class: Encode module needed to use -Encode") | ||||
81 | if ! hasEncode(); | ||||
82 | |||||
83 | my $encoding = Encode::find_encoding($want_encoding); | ||||
84 | |||||
85 | $obj->croakError("$class: Encoding '$want_encoding' is not available") | ||||
86 | if ! $encoding; | ||||
87 | |||||
88 | return $encoding; | ||||
89 | } | ||||
90 | |||||
91 | our ($needBinmode); | ||||
92 | 1 | 35µs | $needBinmode = ($^O eq 'MSWin32' || # spent 6µs executing statements in string eval | ||
93 | ($] >= 5.006 && eval ' ${^UNICODE} || ${^UTF8LOCALE} ')) | ||||
94 | ? 1 : 1 ; | ||||
95 | |||||
96 | sub setBinModeInput($) | ||||
97 | # spent 36µs (29+7) within IO::Compress::Base::Common::setBinModeInput which was called 3 times, avg 12µs/call:
# 3 times (29µs+7µs) by IO::Uncompress::Base::_create at line 437 of IO/Uncompress/Base.pm, avg 12µs/call | ||||
98 | 3 | 1µs | my $handle = shift ; | ||
99 | |||||
100 | 3 | 37µs | 3 | 7µs | binmode $handle # spent 7µs making 3 calls to IO::Compress::Base::Common::CORE:binmode, avg 2µs/call |
101 | if $needBinmode; | ||||
102 | } | ||||
103 | |||||
104 | sub setBinModeOutput($) | ||||
105 | { | ||||
106 | my $handle = shift ; | ||||
107 | |||||
108 | binmode $handle | ||||
109 | if $needBinmode; | ||||
110 | } | ||||
111 | |||||
112 | sub isaFilehandle($) | ||||
113 | # spent 228µs (156+72) within IO::Compress::Base::Common::isaFilehandle which was called 9 times, avg 25µs/call:
# 6 times (48µs+43µs) by IO::Compress::Base::Common::whatIs at line 185, avg 15µs/call
# 3 times (108µs+29µs) by Compress::Zlib::gzopen at line 128 of Compress/Zlib.pm, avg 46µs/call | ||||
114 | 2 | 319µs | 2 | 35µs | # spent 25µs (15+10) within IO::Compress::Base::Common::BEGIN@114 which was called:
# once (15µs+10µs) by Compress::Zlib::BEGIN@10 at line 114 # spent 25µs making 1 call to IO::Compress::Base::Common::BEGIN@114
# spent 10µs making 1 call to utf8::import |
115 | 9 | 196µs | 27 | 72µs | return (defined $_[0] and # spent 72µs making 27 calls to UNIVERSAL::isa, avg 3µs/call |
116 | (UNIVERSAL::isa($_[0],'GLOB') or | ||||
117 | UNIVERSAL::isa($_[0],'IO::Handle') or | ||||
118 | UNIVERSAL::isa(\$_[0],'GLOB')) | ||||
119 | ) | ||||
120 | } | ||||
121 | |||||
122 | sub isaScalar | ||||
123 | { | ||||
124 | return ( defined($_[0]) and ref($_[0]) eq 'SCALAR' and defined ${ $_[0] } ) ; | ||||
125 | } | ||||
126 | |||||
127 | sub isaFilename($) | ||||
128 | # spent 68µs (63+5) within IO::Compress::Base::Common::isaFilename which was called 3 times, avg 23µs/call:
# 3 times (63µs+5µs) by Compress::Zlib::gzopen at line 128 of Compress/Zlib.pm, avg 23µs/call | ||||
129 | 3 | 45µs | 3 | 5µs | return (defined $_[0] and # spent 5µs making 3 calls to UNIVERSAL::isa, avg 2µs/call |
130 | ! ref $_[0] and | ||||
131 | UNIVERSAL::isa(\$_[0], 'SCALAR')); | ||||
132 | } | ||||
133 | |||||
134 | sub isaFileGlobString | ||||
135 | { | ||||
136 | return defined $_[0] && $_[0] =~ /^<.*>$/; | ||||
137 | } | ||||
138 | |||||
139 | sub cleanFileGlobString | ||||
140 | { | ||||
141 | my $string = shift ; | ||||
142 | |||||
143 | $string =~ s/^\s*<\s*(.*)\s*>\s*$/$1/; | ||||
144 | |||||
145 | return $string; | ||||
146 | } | ||||
147 | |||||
148 | 2 | 35µs | 2 | 91µs | # spent 51µs (11+40) within IO::Compress::Base::Common::BEGIN@148 which was called:
# once (11µs+40µs) by Compress::Zlib::BEGIN@10 at line 148 # spent 51µs making 1 call to IO::Compress::Base::Common::BEGIN@148
# spent 40µs making 1 call to constant::import |
149 | 2 | 32µs | 2 | 82µs | # spent 45µs (8+37) within IO::Compress::Base::Common::BEGIN@149 which was called:
# once (8µs+37µs) by Compress::Zlib::BEGIN@10 at line 149 # spent 45µs making 1 call to IO::Compress::Base::Common::BEGIN@149
# spent 37µs making 1 call to constant::import |
150 | 2 | 33µs | 2 | 83µs | # spent 46µs (9+37) within IO::Compress::Base::Common::BEGIN@150 which was called:
# once (9µs+37µs) by Compress::Zlib::BEGIN@10 at line 150 # spent 46µs making 1 call to IO::Compress::Base::Common::BEGIN@150
# spent 37µs making 1 call to constant::import |
151 | #use constant WANT_HASH => 8 ; | ||||
152 | 2 | 1.91ms | 2 | 74µs | # spent 42µs (10+32) within IO::Compress::Base::Common::BEGIN@152 which was called:
# once (10µs+32µs) by Compress::Zlib::BEGIN@10 at line 152 # spent 42µs making 1 call to IO::Compress::Base::Common::BEGIN@152
# spent 32µs making 1 call to constant::import |
153 | |||||
154 | sub whatIsInput($;$) | ||||
155 | # spent 302µs (109+193) within IO::Compress::Base::Common::whatIsInput which was called 6 times, avg 50µs/call:
# 3 times (96µs+136µs) by IO::Uncompress::Base::_create at line 403 of IO/Uncompress/Base.pm, avg 77µs/call
# 3 times (13µs+57µs) by IO::Uncompress::Base::ckInputParam at line 536 of IO/Uncompress/Base.pm, avg 23µs/call | ||||
156 | 6 | 32µs | 6 | 193µs | my $got = whatIs(@_); # spent 193µs making 6 calls to IO::Compress::Base::Common::whatIs, avg 32µs/call |
157 | |||||
158 | 6 | 7µs | if (defined $got && $got eq 'filename' && defined $_[0] && $_[0] eq '-') | ||
159 | { | ||||
160 | #use IO::File; | ||||
161 | $got = 'handle'; | ||||
162 | $_[0] = *STDIN; | ||||
163 | #$_[0] = new IO::File("<-"); | ||||
164 | } | ||||
165 | |||||
166 | 6 | 20µs | return $got; | ||
167 | } | ||||
168 | |||||
169 | sub whatIsOutput($;$) | ||||
170 | { | ||||
171 | my $got = whatIs(@_); | ||||
172 | |||||
173 | if (defined $got && $got eq 'filename' && defined $_[0] && $_[0] eq '-') | ||||
174 | { | ||||
175 | $got = 'handle'; | ||||
176 | $_[0] = *STDOUT; | ||||
177 | #$_[0] = new IO::File(">-"); | ||||
178 | } | ||||
179 | |||||
180 | return $got; | ||||
181 | } | ||||
182 | |||||
183 | sub whatIs ($;$) | ||||
184 | # spent 193µs (102+91) within IO::Compress::Base::Common::whatIs which was called 6 times, avg 32µs/call:
# 6 times (102µs+91µs) by IO::Compress::Base::Common::whatIsInput at line 156, avg 32µs/call | ||||
185 | 6 | 8µs | 6 | 91µs | return 'handle' if isaFilehandle($_[0]); # spent 91µs making 6 calls to IO::Compress::Base::Common::isaFilehandle, avg 15µs/call |
186 | |||||
187 | 6 | 28µs | my $wantCode = defined $_[1] && $_[1] & WANT_CODE ; | ||
188 | 6 | 3µs | my $extended = defined $_[1] && $_[1] & WANT_EXT ; | ||
189 | 6 | 3µs | my $undef = defined $_[1] && $_[1] & WANT_UNDEF ; | ||
190 | 6 | 1µs | my $hash = defined $_[1] && $_[1] & WANT_HASH ; | ||
191 | |||||
192 | 6 | 15µs | return 'undef' if ! defined $_[0] && $undef ; | ||
193 | |||||
194 | 6 | 4µs | if (ref $_[0]) { | ||
195 | return '' if blessed($_[0]); # is an object | ||||
196 | #return '' if UNIVERSAL::isa($_[0], 'UNIVERSAL'); # is an object | ||||
197 | return 'buffer' if UNIVERSAL::isa($_[0], 'SCALAR'); | ||||
198 | return 'array' if UNIVERSAL::isa($_[0], 'ARRAY') && $extended ; | ||||
199 | return 'hash' if UNIVERSAL::isa($_[0], 'HASH') && $hash ; | ||||
200 | return 'code' if UNIVERSAL::isa($_[0], 'CODE') && $wantCode ; | ||||
201 | return ''; | ||||
202 | } | ||||
203 | |||||
204 | 6 | 0s | return 'fileglob' if $extended && isaFileGlobString($_[0]); | ||
205 | 6 | 30µs | return 'filename'; | ||
206 | } | ||||
207 | |||||
208 | sub oneTarget | ||||
209 | { | ||||
210 | return $_[0] =~ /^(code|handle|buffer|filename)$/; | ||||
211 | } | ||||
212 | |||||
213 | sub IO::Compress::Base::Validator::new | ||||
214 | { | ||||
215 | my $class = shift ; | ||||
216 | |||||
217 | my $Class = shift ; | ||||
218 | my $error_ref = shift ; | ||||
219 | my $reportClass = shift ; | ||||
220 | |||||
221 | my %data = (Class => $Class, | ||||
222 | Error => $error_ref, | ||||
223 | reportClass => $reportClass, | ||||
224 | ) ; | ||||
225 | |||||
226 | my $obj = bless \%data, $class ; | ||||
227 | |||||
228 | local $Carp::CarpLevel = 1; | ||||
229 | |||||
230 | my $inType = $data{inType} = whatIsInput($_[0], WANT_EXT|WANT_HASH); | ||||
231 | my $outType = $data{outType} = whatIsOutput($_[1], WANT_EXT|WANT_HASH); | ||||
232 | |||||
233 | my $oneInput = $data{oneInput} = oneTarget($inType); | ||||
234 | my $oneOutput = $data{oneOutput} = oneTarget($outType); | ||||
235 | |||||
236 | if (! $inType) | ||||
237 | { | ||||
238 | $obj->croakError("$reportClass: illegal input parameter") ; | ||||
239 | #return undef ; | ||||
240 | } | ||||
241 | |||||
242 | # if ($inType eq 'hash') | ||||
243 | # { | ||||
244 | # $obj->{Hash} = 1 ; | ||||
245 | # $obj->{oneInput} = 1 ; | ||||
246 | # return $obj->validateHash($_[0]); | ||||
247 | # } | ||||
248 | |||||
249 | if (! $outType) | ||||
250 | { | ||||
251 | $obj->croakError("$reportClass: illegal output parameter") ; | ||||
252 | #return undef ; | ||||
253 | } | ||||
254 | |||||
255 | |||||
256 | if ($inType ne 'fileglob' && $outType eq 'fileglob') | ||||
257 | { | ||||
258 | $obj->croakError("Need input fileglob for outout fileglob"); | ||||
259 | } | ||||
260 | |||||
261 | # if ($inType ne 'fileglob' && $outType eq 'hash' && $inType ne 'filename' ) | ||||
262 | # { | ||||
263 | # $obj->croakError("input must ne filename or fileglob when output is a hash"); | ||||
264 | # } | ||||
265 | |||||
266 | if ($inType eq 'fileglob' && $outType eq 'fileglob') | ||||
267 | { | ||||
268 | $data{GlobMap} = 1 ; | ||||
269 | $data{inType} = $data{outType} = 'filename'; | ||||
270 | my $mapper = new File::GlobMapper($_[0], $_[1]); | ||||
271 | if ( ! $mapper ) | ||||
272 | { | ||||
273 | return $obj->saveErrorString($File::GlobMapper::Error) ; | ||||
274 | } | ||||
275 | $data{Pairs} = $mapper->getFileMap(); | ||||
276 | |||||
277 | return $obj; | ||||
278 | } | ||||
279 | |||||
280 | $obj->croakError("$reportClass: input and output $inType are identical") | ||||
281 | if $inType eq $outType && $_[0] eq $_[1] && $_[0] ne '-' ; | ||||
282 | |||||
283 | if ($inType eq 'fileglob') # && $outType ne 'fileglob' | ||||
284 | { | ||||
285 | my $glob = cleanFileGlobString($_[0]); | ||||
286 | my @inputs = glob($glob); | ||||
287 | |||||
288 | if (@inputs == 0) | ||||
289 | { | ||||
290 | # TODO -- legal or die? | ||||
291 | die "globmap matched zero file -- legal or die???" ; | ||||
292 | } | ||||
293 | elsif (@inputs == 1) | ||||
294 | { | ||||
295 | $obj->validateInputFilenames($inputs[0]) | ||||
296 | or return undef; | ||||
297 | $_[0] = $inputs[0] ; | ||||
298 | $data{inType} = 'filename' ; | ||||
299 | $data{oneInput} = 1; | ||||
300 | } | ||||
301 | else | ||||
302 | { | ||||
303 | $obj->validateInputFilenames(@inputs) | ||||
304 | or return undef; | ||||
305 | $_[0] = [ @inputs ] ; | ||||
306 | $data{inType} = 'filenames' ; | ||||
307 | } | ||||
308 | } | ||||
309 | elsif ($inType eq 'filename') | ||||
310 | { | ||||
311 | $obj->validateInputFilenames($_[0]) | ||||
312 | or return undef; | ||||
313 | } | ||||
314 | elsif ($inType eq 'array') | ||||
315 | { | ||||
316 | $data{inType} = 'filenames' ; | ||||
317 | $obj->validateInputArray($_[0]) | ||||
318 | or return undef ; | ||||
319 | } | ||||
320 | |||||
321 | return $obj->saveErrorString("$reportClass: output buffer is read-only") | ||||
322 | if $outType eq 'buffer' && readonly(${ $_[1] }); | ||||
323 | |||||
324 | if ($outType eq 'filename' ) | ||||
325 | { | ||||
326 | $obj->croakError("$reportClass: output filename is undef or null string") | ||||
327 | if ! defined $_[1] || $_[1] eq '' ; | ||||
328 | |||||
329 | if (-e $_[1]) | ||||
330 | { | ||||
331 | if (-d _ ) | ||||
332 | { | ||||
333 | return $obj->saveErrorString("output file '$_[1]' is a directory"); | ||||
334 | } | ||||
335 | } | ||||
336 | } | ||||
337 | |||||
338 | return $obj ; | ||||
339 | } | ||||
340 | |||||
341 | sub IO::Compress::Base::Validator::saveErrorString | ||||
342 | { | ||||
343 | my $self = shift ; | ||||
344 | ${ $self->{Error} } = shift ; | ||||
345 | return undef; | ||||
346 | |||||
347 | } | ||||
348 | |||||
349 | sub IO::Compress::Base::Validator::croakError | ||||
350 | { | ||||
351 | my $self = shift ; | ||||
352 | $self->saveErrorString($_[0]); | ||||
353 | croak $_[0]; | ||||
354 | } | ||||
355 | |||||
- - | |||||
358 | sub IO::Compress::Base::Validator::validateInputFilenames | ||||
359 | { | ||||
360 | my $self = shift ; | ||||
361 | |||||
362 | foreach my $filename (@_) | ||||
363 | { | ||||
364 | $self->croakError("$self->{reportClass}: input filename is undef or null string") | ||||
365 | if ! defined $filename || $filename eq '' ; | ||||
366 | |||||
367 | next if $filename eq '-'; | ||||
368 | |||||
369 | if (! -e $filename ) | ||||
370 | { | ||||
371 | return $self->saveErrorString("input file '$filename' does not exist"); | ||||
372 | } | ||||
373 | |||||
374 | if (-d _ ) | ||||
375 | { | ||||
376 | return $self->saveErrorString("input file '$filename' is a directory"); | ||||
377 | } | ||||
378 | |||||
379 | # if (! -r _ ) | ||||
380 | # { | ||||
381 | # return $self->saveErrorString("cannot open file '$filename': $!"); | ||||
382 | # } | ||||
383 | } | ||||
384 | |||||
385 | return 1 ; | ||||
386 | } | ||||
387 | |||||
388 | sub IO::Compress::Base::Validator::validateInputArray | ||||
389 | { | ||||
390 | my $self = shift ; | ||||
391 | |||||
392 | if ( @{ $_[0] } == 0 ) | ||||
393 | { | ||||
394 | return $self->saveErrorString("empty array reference") ; | ||||
395 | } | ||||
396 | |||||
397 | foreach my $element ( @{ $_[0] } ) | ||||
398 | { | ||||
399 | my $inType = whatIsInput($element); | ||||
400 | |||||
401 | if (! $inType) | ||||
402 | { | ||||
403 | $self->croakError("unknown input parameter") ; | ||||
404 | } | ||||
405 | elsif($inType eq 'filename') | ||||
406 | { | ||||
407 | $self->validateInputFilenames($element) | ||||
408 | or return undef ; | ||||
409 | } | ||||
410 | else | ||||
411 | { | ||||
412 | $self->croakError("not a filename") ; | ||||
413 | } | ||||
414 | } | ||||
415 | |||||
416 | return 1 ; | ||||
417 | } | ||||
418 | |||||
419 | #sub IO::Compress::Base::Validator::validateHash | ||||
420 | #{ | ||||
421 | # my $self = shift ; | ||||
422 | # my $href = shift ; | ||||
423 | # | ||||
424 | # while (my($k, $v) = each %$href) | ||||
425 | # { | ||||
426 | # my $ktype = whatIsInput($k); | ||||
427 | # my $vtype = whatIsOutput($v, WANT_EXT|WANT_UNDEF) ; | ||||
428 | # | ||||
429 | # if ($ktype ne 'filename') | ||||
430 | # { | ||||
431 | # return $self->saveErrorString("hash key not filename") ; | ||||
432 | # } | ||||
433 | # | ||||
434 | # my %valid = map { $_ => 1 } qw(filename buffer array undef handle) ; | ||||
435 | # if (! $valid{$vtype}) | ||||
436 | # { | ||||
437 | # return $self->saveErrorString("hash value not ok") ; | ||||
438 | # } | ||||
439 | # } | ||||
440 | # | ||||
441 | # return $self ; | ||||
442 | #} | ||||
443 | |||||
444 | sub createSelfTiedObject | ||||
445 | # spent 365µs (232+133) within IO::Compress::Base::Common::createSelfTiedObject which was called 3 times, avg 122µs/call:
# 3 times (232µs+133µs) by IO::Uncompress::Gunzip::new at line 37 of IO/Uncompress/Gunzip.pm, avg 122µs/call | ||||
446 | 3 | 1µs | my $class = shift || (caller)[0] ; | ||
447 | 3 | 1µs | my $error_ref = shift ; | ||
448 | |||||
449 | 3 | 11µs | 3 | 42µs | my $obj = bless Symbol::gensym(), ref($class) || $class; # spent 42µs making 3 calls to Symbol::gensym, avg 14µs/call |
450 | 3 | 183µs | 3 | 91µs | tie *$obj, $obj if $] >= 5.005; # spent 91µs making 3 calls to IO::Uncompress::Base::TIEHANDLE, avg 30µs/call |
451 | 3 | 8µs | *$obj->{Closed} = 1 ; | ||
452 | 3 | 3µs | $$error_ref = ''; | ||
453 | 3 | 7µs | *$obj->{Error} = $error_ref ; | ||
454 | 3 | 1µs | my $errno = 0 ; | ||
455 | 3 | 3µs | *$obj->{ErrorNo} = \$errno ; | ||
456 | |||||
457 | 3 | 59µs | return $obj; | ||
458 | } | ||||
459 | |||||
- - | |||||
462 | #package Parse::Parameters ; | ||||
463 | # | ||||
464 | # | ||||
465 | #require Exporter; | ||||
466 | #our ($VERSION, @ISA, @EXPORT); | ||||
467 | #$VERSION = '2.000_08'; | ||||
468 | #@ISA = qw(Exporter); | ||||
469 | |||||
470 | 1 | 2µs | $EXPORT_TAGS{Parse} = [qw( ParseParameters | ||
471 | Parse_any Parse_unsigned Parse_signed | ||||
472 | Parse_boolean Parse_string | ||||
473 | Parse_code | ||||
474 | Parse_writable_scalar | ||||
475 | ) | ||||
476 | ]; | ||||
477 | |||||
478 | 1 | 3µs | push @EXPORT, @{ $EXPORT_TAGS{Parse} } ; | ||
479 | |||||
480 | 2 | 39µs | 2 | 112µs | # spent 63µs (14+49) within IO::Compress::Base::Common::BEGIN@480 which was called:
# once (14µs+49µs) by Compress::Zlib::BEGIN@10 at line 480 # spent 63µs making 1 call to IO::Compress::Base::Common::BEGIN@480
# spent 49µs making 1 call to constant::import |
481 | 2 | 33µs | 2 | 83µs | # spent 46µs (9+37) within IO::Compress::Base::Common::BEGIN@481 which was called:
# once (9µs+37µs) by Compress::Zlib::BEGIN@10 at line 481 # spent 46µs making 1 call to IO::Compress::Base::Common::BEGIN@481
# spent 37µs making 1 call to constant::import |
482 | 2 | 38µs | 2 | 76µs | # spent 42µs (8+34) within IO::Compress::Base::Common::BEGIN@482 which was called:
# once (8µs+34µs) by Compress::Zlib::BEGIN@10 at line 482 # spent 42µs making 1 call to IO::Compress::Base::Common::BEGIN@482
# spent 34µs making 1 call to constant::import |
483 | 2 | 31µs | 2 | 79µs | # spent 44µs (9+35) within IO::Compress::Base::Common::BEGIN@483 which was called:
# once (9µs+35µs) by Compress::Zlib::BEGIN@10 at line 483 # spent 44µs making 1 call to IO::Compress::Base::Common::BEGIN@483
# spent 35µs making 1 call to constant::import |
484 | 2 | 30µs | 2 | 77µs | # spent 43µs (9+34) within IO::Compress::Base::Common::BEGIN@484 which was called:
# once (9µs+34µs) by Compress::Zlib::BEGIN@10 at line 484 # spent 43µs making 1 call to IO::Compress::Base::Common::BEGIN@484
# spent 34µs making 1 call to constant::import |
485 | 2 | 32µs | 2 | 74µs | # spent 41µs (8+33) within IO::Compress::Base::Common::BEGIN@485 which was called:
# once (8µs+33µs) by Compress::Zlib::BEGIN@10 at line 485 # spent 41µs making 1 call to IO::Compress::Base::Common::BEGIN@485
# spent 33µs making 1 call to constant::import |
486 | |||||
487 | #use constant Parse_store_ref => 0x100 ; | ||||
488 | #use constant Parse_multiple => 0x100 ; | ||||
489 | 2 | 42µs | 2 | 74µs | # spent 41µs (8+33) within IO::Compress::Base::Common::BEGIN@489 which was called:
# once (8µs+33µs) by Compress::Zlib::BEGIN@10 at line 489 # spent 41µs making 1 call to IO::Compress::Base::Common::BEGIN@489
# spent 33µs making 1 call to constant::import |
490 | 2 | 32µs | 2 | 84µs | # spent 46µs (8+38) within IO::Compress::Base::Common::BEGIN@490 which was called:
# once (8µs+38µs) by Compress::Zlib::BEGIN@10 at line 490 # spent 46µs making 1 call to IO::Compress::Base::Common::BEGIN@490
# spent 38µs making 1 call to constant::import |
491 | |||||
492 | 2 | 31µs | 2 | 74µs | # spent 41µs (8+33) within IO::Compress::Base::Common::BEGIN@492 which was called:
# once (8µs+33µs) by Compress::Zlib::BEGIN@10 at line 492 # spent 41µs making 1 call to IO::Compress::Base::Common::BEGIN@492
# spent 33µs making 1 call to constant::import |
493 | 2 | 32µs | 2 | 82µs | # spent 45µs (8+37) within IO::Compress::Base::Common::BEGIN@493 which was called:
# once (8µs+37µs) by Compress::Zlib::BEGIN@10 at line 493 # spent 45µs making 1 call to IO::Compress::Base::Common::BEGIN@493
# spent 37µs making 1 call to constant::import |
494 | 2 | 31µs | 2 | 78µs | # spent 43µs (8+35) within IO::Compress::Base::Common::BEGIN@494 which was called:
# once (8µs+35µs) by Compress::Zlib::BEGIN@10 at line 494 # spent 43µs making 1 call to IO::Compress::Base::Common::BEGIN@494
# spent 35µs making 1 call to constant::import |
495 | 2 | 30µs | 2 | 71µs | # spent 40µs (9+31) within IO::Compress::Base::Common::BEGIN@495 which was called:
# once (9µs+31µs) by Compress::Zlib::BEGIN@10 at line 495 # spent 40µs making 1 call to IO::Compress::Base::Common::BEGIN@495
# spent 31µs making 1 call to constant::import |
496 | #use constant OFF_FIRST_ONLY => 4 ; | ||||
497 | #use constant OFF_STICKY => 5 ; | ||||
498 | |||||
499 | 2 | 35µs | 2 | 78µs | # spent 43µs (8+35) within IO::Compress::Base::Common::BEGIN@499 which was called:
# once (8µs+35µs) by Compress::Zlib::BEGIN@10 at line 499 # spent 43µs making 1 call to IO::Compress::Base::Common::BEGIN@499
# spent 35µs making 1 call to constant::import |
500 | 2 | 149µs | 2 | 79µs | # spent 44µs (9+35) within IO::Compress::Base::Common::BEGIN@500 which was called:
# once (9µs+35µs) by Compress::Zlib::BEGIN@10 at line 500 # spent 44µs making 1 call to IO::Compress::Base::Common::BEGIN@500
# spent 35µs making 1 call to constant::import |
501 | |||||
502 | sub ParseParameters | ||||
503 | { | ||||
504 | my $level = shift || 0 ; | ||||
505 | |||||
506 | my $sub = (caller($level + 1))[3] ; | ||||
507 | local $Carp::CarpLevel = 1 ; | ||||
508 | |||||
509 | return $_[1] | ||||
510 | if @_ == 2 && defined $_[1] && UNIVERSAL::isa($_[1], "IO::Compress::Base::Parameters"); | ||||
511 | |||||
512 | my $p = new IO::Compress::Base::Parameters() ; | ||||
513 | $p->parse(@_) | ||||
514 | or croak "$sub: $p->[IxError]" ; | ||||
515 | |||||
516 | return $p; | ||||
517 | } | ||||
518 | |||||
519 | |||||
520 | 2 | 38µs | 2 | 20µs | # spent 17µs (14+3) within IO::Compress::Base::Common::BEGIN@520 which was called:
# once (14µs+3µs) by Compress::Zlib::BEGIN@10 at line 520 # spent 17µs making 1 call to IO::Compress::Base::Common::BEGIN@520
# spent 3µs making 1 call to strict::import |
521 | |||||
522 | 2 | 29µs | 2 | 36µs | # spent 24µs (12+12) within IO::Compress::Base::Common::BEGIN@522 which was called:
# once (12µs+12µs) by Compress::Zlib::BEGIN@10 at line 522 # spent 24µs making 1 call to IO::Compress::Base::Common::BEGIN@522
# spent 12µs making 1 call to warnings::import |
523 | 2 | 1.58ms | 2 | 105µs | # spent 58µs (11+47) within IO::Compress::Base::Common::BEGIN@523 which was called:
# once (11µs+47µs) by Compress::Zlib::BEGIN@10 at line 523 # spent 58µs making 1 call to IO::Compress::Base::Common::BEGIN@523
# spent 47µs making 1 call to Exporter::import |
524 | |||||
525 | |||||
526 | sub Init | ||||
527 | { | ||||
528 | my $default = shift ; | ||||
529 | my %got ; | ||||
530 | |||||
531 | my $obj = IO::Compress::Base::Parameters::new(); | ||||
532 | while (my ($key, $v) = each %$default) | ||||
533 | { | ||||
534 | croak "need 2 params [@$v]" | ||||
535 | if @$v != 2 ; | ||||
536 | |||||
537 | my ($type, $value) = @$v ; | ||||
538 | # my ($first_only, $sticky, $type, $value) = @$v ; | ||||
539 | my $sticky = 0; | ||||
540 | my $x ; | ||||
541 | $obj->_checkType($key, \$value, $type, 0, \$x) | ||||
542 | or return undef ; | ||||
543 | |||||
544 | $key = lc $key; | ||||
545 | |||||
546 | # if (! $sticky) { | ||||
547 | # $x = [] | ||||
548 | # if $type & Parse_multiple; | ||||
549 | |||||
550 | # $got{$key} = [0, $type, $value, $x, $first_only, $sticky] ; | ||||
551 | $got{$key} = [0, $type, $value, $x] ; | ||||
552 | # } | ||||
553 | # | ||||
554 | # $got{$key}[OFF_PARSED] = 0 ; | ||||
555 | } | ||||
556 | |||||
557 | return bless \%got, "IO::Compress::Base::Parameters::Defaults" ; | ||||
558 | } | ||||
559 | |||||
560 | sub IO::Compress::Base::Parameters::new | ||||
561 | # spent 52µs within IO::Compress::Base::Parameters::new which was called 3 times, avg 17µs/call:
# 3 times (52µs+0s) by IO::Uncompress::Base::checkParams at line 348 of IO/Uncompress/Base.pm, avg 17µs/call | ||||
562 | #my $class = shift ; | ||||
563 | |||||
564 | 3 | 0s | my $obj; | ||
565 | 3 | 7µs | $obj->[IxError] = ''; | ||
566 | 3 | 4µs | $obj->[IxGot] = {} ; | ||
567 | |||||
568 | 3 | 30µs | return bless $obj, 'IO::Compress::Base::Parameters' ; | ||
569 | } | ||||
570 | |||||
571 | sub IO::Compress::Base::Parameters::setError | ||||
572 | { | ||||
573 | my $self = shift ; | ||||
574 | my $error = shift ; | ||||
575 | my $retval = @_ ? shift : undef ; | ||||
576 | |||||
577 | |||||
578 | $self->[IxError] = $error ; | ||||
579 | return $retval; | ||||
580 | } | ||||
581 | |||||
582 | sub IO::Compress::Base::Parameters::getError | ||||
583 | { | ||||
584 | my $self = shift ; | ||||
585 | return $self->[IxError] ; | ||||
586 | } | ||||
587 | |||||
588 | sub IO::Compress::Base::Parameters::parse | ||||
589 | # spent 575µs (395+180) within IO::Compress::Base::Parameters::parse which was called 3 times, avg 192µs/call:
# 3 times (395µs+180µs) by IO::Uncompress::Base::checkParams at line 374 of IO/Uncompress/Base.pm, avg 192µs/call | ||||
590 | 3 | 0s | my $self = shift ; | ||
591 | 3 | 3µs | my $default = shift ; | ||
592 | |||||
593 | 3 | 7µs | my $got = $self->[IxGot] ; | ||
594 | 3 | 5µs | my $firstTime = keys %{ $got } == 0 ; | ||
595 | |||||
596 | 3 | 1µs | my (@Bad) ; | ||
597 | 3 | 2µs | my @entered = () ; | ||
598 | |||||
599 | # Allow the options to be passed as a hash reference or | ||||
600 | # as the complete hash. | ||||
601 | 3 | 6µs | if (@_ == 0) { | ||
602 | @entered = () ; | ||||
603 | } | ||||
604 | elsif (@_ == 1) { | ||||
605 | my $href = $_[0] ; | ||||
606 | |||||
607 | return $self->setError("Expected even number of parameters, got 1") | ||||
608 | if ! defined $href or ! ref $href or ref $href ne "HASH" ; | ||||
609 | |||||
610 | foreach my $key (keys %$href) { | ||||
611 | push @entered, $key ; | ||||
612 | push @entered, \$href->{$key} ; | ||||
613 | } | ||||
614 | } | ||||
615 | else { | ||||
616 | |||||
617 | 3 | 1µs | my $count = @_; | ||
618 | 3 | 3µs | return $self->setError("Expected even number of parameters, got $count") | ||
619 | if $count % 2 != 0 ; | ||||
620 | |||||
621 | 3 | 16µs | for my $i (0.. $count / 2 - 1) { | ||
622 | 15 | 11µs | push @entered, $_[2 * $i] ; | ||
623 | 15 | 13µs | push @entered, \$_[2 * $i + 1] ; | ||
624 | } | ||||
625 | } | ||||
626 | |||||
627 | 3 | 14µs | foreach my $key (keys %$default) | ||
628 | { | ||||
629 | |||||
630 | 33 | 16µs | my ($type, $value) = @{ $default->{$key} } ; | ||
631 | |||||
632 | 33 | 58µs | if ($firstTime) { | ||
633 | $got->{$key} = [0, $type, $value, $value] ; | ||||
634 | } | ||||
635 | else | ||||
636 | { | ||||
637 | $got->{$key}[OFF_PARSED] = 0 ; | ||||
638 | } | ||||
639 | } | ||||
640 | |||||
641 | |||||
642 | 3 | 5µs | my %parsed = (); | ||
643 | |||||
644 | |||||
645 | 3 | 7µs | for my $i (0.. @entered / 2 - 1) { | ||
646 | 15 | 10µs | my $key = $entered[2* $i] ; | ||
647 | 15 | 5µs | my $value = $entered[2* $i+1] ; | ||
648 | |||||
649 | #print "Key [$key] Value [$value]" ; | ||||
650 | #print defined $$value ? "[$$value]\n" : "[undef]\n"; | ||||
651 | |||||
652 | 15 | 52µs | 15 | 18µs | $key =~ s/^-// ; # spent 18µs making 15 calls to IO::Compress::Base::Common::CORE:subst, avg 1µs/call |
653 | 15 | 17µs | my $canonkey = lc $key; | ||
654 | |||||
655 | 15 | 18µs | if ($got->{$canonkey}) | ||
656 | { | ||||
657 | 15 | 7µs | my $type = $got->{$canonkey}[OFF_TYPE] ; | ||
658 | 15 | 8µs | my $parsed = $parsed{$canonkey}; | ||
659 | 15 | 11µs | ++ $parsed{$canonkey}; | ||
660 | |||||
661 | 15 | 3µs | return $self->setError("Muliple instances of '$key' found") | ||
662 | if $parsed ; | ||||
663 | |||||
664 | 15 | 2µs | my $s ; | ||
665 | 15 | 32µs | 15 | 162µs | $self->_checkType($key, $value, $type, 1, \$s) # spent 162µs making 15 calls to IO::Compress::Base::Parameters::_checkType, avg 11µs/call |
666 | or return undef ; | ||||
667 | |||||
668 | 15 | 1µs | $value = $$value ; | ||
669 | 15 | 32µs | $got->{$canonkey} = [1, $type, $value, $s] ; | ||
670 | |||||
671 | } | ||||
672 | else | ||||
673 | { push (@Bad, $key) } | ||||
674 | } | ||||
675 | |||||
676 | 3 | 3µs | if (@Bad) { | ||
677 | my ($bad) = join(", ", @Bad) ; | ||||
678 | return $self->setError("unknown key value(s) $bad") ; | ||||
679 | } | ||||
680 | |||||
681 | 3 | 17µs | return 1; | ||
682 | } | ||||
683 | |||||
684 | sub IO::Compress::Base::Parameters::_checkType | ||||
685 | # spent 162µs (125+37) within IO::Compress::Base::Parameters::_checkType which was called 15 times, avg 11µs/call:
# 15 times (125µs+37µs) by IO::Compress::Base::Parameters::parse at line 665, avg 11µs/call | ||||
686 | 15 | 5µs | my $self = shift ; | ||
687 | |||||
688 | 15 | 3µs | my $key = shift ; | ||
689 | 15 | 5µs | my $value = shift ; | ||
690 | 15 | 3µs | my $type = shift ; | ||
691 | 15 | 5µs | my $validate = shift ; | ||
692 | 15 | 2µs | my $output = shift; | ||
693 | |||||
694 | #local $Carp::CarpLevel = $level ; | ||||
695 | #print "PARSE $type $key $value $validate $sub\n" ; | ||||
696 | |||||
697 | 15 | 6µs | if ($type & Parse_writable_scalar) | ||
698 | { | ||||
699 | return $self->setError("Parameter '$key' not writable") | ||||
700 | if readonly $$value ; | ||||
701 | |||||
702 | if (ref $$value) | ||||
703 | { | ||||
704 | return $self->setError("Parameter '$key' not a scalar reference") | ||||
705 | if ref $$value ne 'SCALAR' ; | ||||
706 | |||||
707 | $$output = $$value ; | ||||
708 | } | ||||
709 | else | ||||
710 | { | ||||
711 | return $self->setError("Parameter '$key' not a scalar") | ||||
712 | if ref $value ne 'SCALAR' ; | ||||
713 | |||||
714 | $$output = $value ; | ||||
715 | } | ||||
716 | |||||
717 | return 1; | ||||
718 | } | ||||
719 | |||||
720 | |||||
721 | 15 | 5µs | $value = $$value ; | ||
722 | |||||
723 | 15 | 13µs | if ($type & Parse_any) | ||
724 | { | ||||
725 | 3 | 0s | $$output = $value ; | ||
726 | 3 | 28µs | return 1; | ||
727 | } | ||||
728 | elsif ($type & Parse_unsigned) | ||||
729 | { | ||||
730 | |||||
731 | return $self->setError("Parameter '$key' must be an unsigned int, got 'undef'") | ||||
732 | if ! defined $value ; | ||||
733 | return $self->setError("Parameter '$key' must be an unsigned int, got '$value'") | ||||
734 | if $value !~ /^\d+$/; | ||||
735 | |||||
736 | $$output = defined $value ? $value : 0 ; | ||||
737 | return 1; | ||||
738 | } | ||||
739 | elsif ($type & Parse_signed) | ||||
740 | { | ||||
741 | return $self->setError("Parameter '$key' must be a signed int, got 'undef'") | ||||
742 | if ! defined $value ; | ||||
743 | return $self->setError("Parameter '$key' must be a signed int, got '$value'") | ||||
744 | if $value !~ /^-?\d+$/; | ||||
745 | |||||
746 | $$output = defined $value ? $value : 0 ; | ||||
747 | return 1 ; | ||||
748 | } | ||||
749 | elsif ($type & Parse_boolean) | ||||
750 | { | ||||
751 | 12 | 75µs | 12 | 37µs | return $self->setError("Parameter '$key' must be an int, got '$value'") # spent 37µs making 12 calls to IO::Compress::Base::Common::CORE:match, avg 3µs/call |
752 | if defined $value && $value !~ /^\d*$/; | ||||
753 | |||||
754 | 12 | 12µs | $$output = defined $value && $value != 0 ? 1 : 0 ; | ||
755 | 12 | 32µs | return 1; | ||
756 | } | ||||
757 | |||||
758 | elsif ($type & Parse_string) | ||||
759 | { | ||||
760 | $$output = defined $value ? $value : "" ; | ||||
761 | return 1; | ||||
762 | } | ||||
763 | elsif ($type & Parse_code) | ||||
764 | { | ||||
765 | return $self->setError("Parameter '$key' must be a code reference, got '$value'") | ||||
766 | if (! defined $value || ref $value ne 'CODE') ; | ||||
767 | |||||
768 | $$output = defined $value ? $value : "" ; | ||||
769 | return 1; | ||||
770 | } | ||||
771 | |||||
772 | $$output = $value ; | ||||
773 | return 1; | ||||
774 | } | ||||
775 | |||||
776 | sub IO::Compress::Base::Parameters::parsed | ||||
777 | # spent 7µs within IO::Compress::Base::Parameters::parsed which was called 3 times, avg 2µs/call:
# 3 times (7µs+0s) by IO::Uncompress::Base::_create at line 451 of IO/Uncompress/Base.pm, avg 2µs/call | ||||
778 | 3 | 13µs | return $_[0]->[IxGot]{$_[1]}[OFF_PARSED] ; | ||
779 | } | ||||
780 | |||||
781 | |||||
782 | sub IO::Compress::Base::Parameters::getValue | ||||
783 | # spent 93µs within IO::Compress::Base::Parameters::getValue which was called 51 times, avg 2µs/call:
# 9 times (19µs+0s) by IO::Uncompress::RawInflate::mkUncomp at line 76 of IO/Uncompress/RawInflate.pm, avg 2µs/call
# 6 times (12µs+0s) by IO::Uncompress::Base::_create at line 467 of IO/Uncompress/Base.pm, avg 2µs/call
# 3 times (9µs+0s) by IO::Uncompress::Base::_create at line 454 of IO/Uncompress/Base.pm, avg 3µs/call
# 3 times (8µs+0s) by IO::Uncompress::Base::_create at line 430 of IO/Uncompress/Base.pm, avg 3µs/call
# 3 times (8µs+0s) by IO::Uncompress::Base::_create at line 470 of IO/Uncompress/Base.pm, avg 3µs/call
# 3 times (6µs+0s) by IO::Uncompress::Base::_create at line 461 of IO/Uncompress/Base.pm, avg 2µs/call
# 3 times (5µs+0s) by IO::Uncompress::Base::_create at line 466 of IO/Uncompress/Base.pm, avg 2µs/call
# 3 times (5µs+0s) by IO::Uncompress::Base::_create at line 460 of IO/Uncompress/Base.pm, avg 2µs/call
# 3 times (5µs+0s) by IO::Uncompress::Base::_create at line 462 of IO/Uncompress/Base.pm, avg 2µs/call
# 3 times (4µs+0s) by IO::Uncompress::Base::_create at line 459 of IO/Uncompress/Base.pm, avg 1µs/call
# 3 times (4µs+0s) by IO::Uncompress::Base::_create at line 456 of IO/Uncompress/Base.pm, avg 1µs/call
# 3 times (3µs+0s) by IO::Uncompress::Base::_create at line 463 of IO/Uncompress/Base.pm, avg 1µs/call
# 3 times (3µs+0s) by IO::Uncompress::Base::_create at line 458 of IO/Uncompress/Base.pm, avg 1µs/call
# 3 times (2µs+0s) by IO::Uncompress::Base::_create at line 457 of IO/Uncompress/Base.pm, avg 667ns/call | ||||
784 | 51 | 168µs | return $_[0]->[IxGot]{$_[1]}[OFF_FIXED] ; | ||
785 | } | ||||
786 | sub IO::Compress::Base::Parameters::setValue | ||||
787 | # spent 22µs within IO::Compress::Base::Parameters::setValue which was called 3 times, avg 7µs/call:
# 3 times (22µs+0s) by IO::Uncompress::Gunzip::ckParams at line 59 of IO/Uncompress/Gunzip.pm, avg 7µs/call | ||||
788 | 3 | 7µs | $_[0]->[IxGot]{$_[1]}[OFF_PARSED] = 1; | ||
789 | 3 | 4µs | $_[0]->[IxGot]{$_[1]}[OFF_DEFAULT] = $_[2] ; | ||
790 | 3 | 11µs | $_[0]->[IxGot]{$_[1]}[OFF_FIXED] = $_[2] ; | ||
791 | } | ||||
792 | |||||
793 | sub IO::Compress::Base::Parameters::valueRef | ||||
794 | { | ||||
795 | return $_[0]->[IxGot]{$_[1]}[OFF_FIXED] ; | ||||
796 | } | ||||
797 | |||||
798 | sub IO::Compress::Base::Parameters::valueOrDefault | ||||
799 | { | ||||
800 | my $self = shift ; | ||||
801 | my $name = shift ; | ||||
802 | my $default = shift ; | ||||
803 | |||||
804 | my $value = $self->[IxGot]{$name}[OFF_DEFAULT] ; | ||||
805 | |||||
806 | return $value if defined $value ; | ||||
807 | return $default ; | ||||
808 | } | ||||
809 | |||||
810 | sub IO::Compress::Base::Parameters::wantValue | ||||
811 | { | ||||
812 | return defined $_[0]->[IxGot]{$_[1]}[OFF_DEFAULT] ; | ||||
813 | } | ||||
814 | |||||
815 | sub IO::Compress::Base::Parameters::clone | ||||
816 | { | ||||
817 | my $self = shift ; | ||||
818 | my $obj = [] ; | ||||
819 | my %got ; | ||||
820 | |||||
821 | my $hash = $self->[IxGot] ; | ||||
822 | for my $k (keys %{ $hash }) | ||||
823 | { | ||||
824 | $got{$k} = [ @{ $hash->{$k} } ]; | ||||
825 | } | ||||
826 | |||||
827 | $obj->[IxError] = $self->[IxError]; | ||||
828 | $obj->[IxGot] = \%got ; | ||||
829 | |||||
830 | return bless $obj, 'IO::Compress::Base::Parameters' ; | ||||
831 | } | ||||
832 | |||||
833 | package U64; | ||||
834 | |||||
835 | 2 | 42µs | 2 | 100µs | # spent 56µs (12+44) within U64::BEGIN@835 which was called:
# once (12µs+44µs) by Compress::Zlib::BEGIN@10 at line 835 # spent 56µs making 1 call to U64::BEGIN@835
# spent 44µs making 1 call to constant::import |
836 | 2 | 44µs | 2 | 84µs | # spent 47µs (10+37) within U64::BEGIN@836 which was called:
# once (10µs+37µs) by Compress::Zlib::BEGIN@10 at line 836 # spent 47µs making 1 call to U64::BEGIN@836
# spent 37µs making 1 call to constant::import |
837 | 2 | 34µs | 2 | 88µs | # spent 49µs (10+39) within U64::BEGIN@837 which was called:
# once (10µs+39µs) by Compress::Zlib::BEGIN@10 at line 837 # spent 49µs making 1 call to U64::BEGIN@837
# spent 39µs making 1 call to constant::import |
838 | 2 | 1.04ms | 2 | 74µs | # spent 42µs (10+32) within U64::BEGIN@838 which was called:
# once (10µs+32µs) by Compress::Zlib::BEGIN@10 at line 838 # spent 42µs making 1 call to U64::BEGIN@838
# spent 32µs making 1 call to constant::import |
839 | |||||
840 | sub new | ||||
841 | # spent 26µs within U64::new which was called 6 times, avg 4µs/call:
# 3 times (21µs+0s) by IO::Uncompress::Base::_create at line 475 of IO/Uncompress/Base.pm, avg 7µs/call
# 3 times (5µs+0s) by IO::Uncompress::Base::_create at line 476 of IO/Uncompress/Base.pm, avg 2µs/call | ||||
842 | 6 | 35µs | return bless [ 0, 0 ], $_[0] | ||
843 | if @_ == 1 ; | ||||
844 | |||||
845 | return bless [ $_[1], 0 ], $_[0] | ||||
846 | if @_ == 2 ; | ||||
847 | |||||
848 | return bless [ $_[2], $_[1] ], $_[0] | ||||
849 | if @_ == 3 ; | ||||
850 | } | ||||
851 | |||||
852 | sub newUnpack_V64 | ||||
853 | { | ||||
854 | my ($low, $hi) = unpack "V V", $_[0] ; | ||||
855 | bless [ $low, $hi ], "U64"; | ||||
856 | } | ||||
857 | |||||
858 | sub newUnpack_V32 | ||||
859 | { | ||||
860 | my $string = shift; | ||||
861 | |||||
862 | my $low = unpack "V", $string ; | ||||
863 | bless [ $low, 0 ], "U64"; | ||||
864 | } | ||||
865 | |||||
866 | sub reset | ||||
867 | { | ||||
868 | $_[0]->[HIGH] = $_[0]->[LOW] = 0; | ||||
869 | } | ||||
870 | |||||
871 | sub clone | ||||
872 | { | ||||
873 | bless [ @{$_[0]} ], ref $_[0] ; | ||||
874 | } | ||||
875 | |||||
876 | sub getHigh | ||||
877 | { | ||||
878 | return $_[0]->[HIGH]; | ||||
879 | } | ||||
880 | |||||
881 | sub getLow | ||||
882 | { | ||||
883 | return $_[0]->[LOW]; | ||||
884 | } | ||||
885 | |||||
886 | sub get32bit | ||||
887 | { | ||||
888 | return $_[0]->[LOW]; | ||||
889 | } | ||||
890 | |||||
891 | sub get64bit | ||||
892 | { | ||||
893 | # Not using << here because the result will still be | ||||
894 | # a 32-bit value on systems where int size is 32-bits | ||||
895 | return $_[0]->[HIGH] * HI_1 + $_[0]->[LOW]; | ||||
896 | } | ||||
897 | |||||
898 | sub add | ||||
899 | # spent 2.78ms within U64::add which was called 1262 times, avg 2µs/call:
# 631 times (1.64ms+0s) by IO::Uncompress::Base::_raw_read at line 926 of IO/Uncompress/Base.pm, avg 3µs/call
# 631 times (1.13ms+0s) by IO::Uncompress::Base::_raw_read at line 930 of IO/Uncompress/Base.pm, avg 2µs/call | ||||
900 | # my $self = shift; | ||||
901 | 1262 | 228µs | my $value = $_[1]; | ||
902 | |||||
903 | 1262 | 474µs | if (ref $value eq 'U64') { | ||
904 | $_[0]->[HIGH] += $value->[HIGH] ; | ||||
905 | $value = $value->[LOW]; | ||||
906 | } | ||||
907 | elsif ($value > MAX32) { | ||||
908 | $_[0]->[HIGH] += int($value / HI_1) ; | ||||
909 | $value = $value % HI_1; | ||||
910 | } | ||||
911 | |||||
912 | 1262 | 386µs | my $available = MAX32 - $_[0]->[LOW] ; | ||
913 | |||||
914 | 1262 | 2.51ms | if ($value > $available) { | ||
915 | ++ $_[0]->[HIGH] ; | ||||
916 | $_[0]->[LOW] = $value - $available - 1; | ||||
917 | } | ||||
918 | else { | ||||
919 | 1262 | 282µs | $_[0]->[LOW] += $value ; | ||
920 | } | ||||
921 | } | ||||
922 | |||||
923 | sub add32 | ||||
924 | { | ||||
925 | # my $self = shift; | ||||
926 | my $value = $_[1]; | ||||
927 | |||||
928 | if ($value > MAX32) { | ||||
929 | $_[0]->[HIGH] += int($value / HI_1) ; | ||||
930 | $value = $value % HI_1; | ||||
931 | } | ||||
932 | |||||
933 | my $available = MAX32 - $_[0]->[LOW] ; | ||||
934 | |||||
935 | if ($value > $available) { | ||||
936 | ++ $_[0]->[HIGH] ; | ||||
937 | $_[0]->[LOW] = $value - $available - 1; | ||||
938 | } | ||||
939 | else { | ||||
940 | $_[0]->[LOW] += $value ; | ||||
941 | } | ||||
942 | } | ||||
943 | |||||
944 | sub subtract | ||||
945 | { | ||||
946 | my $self = shift; | ||||
947 | my $value = shift; | ||||
948 | |||||
949 | if (ref $value eq 'U64') { | ||||
950 | |||||
951 | if ($value->[HIGH]) { | ||||
952 | die "bad" | ||||
953 | if $self->[HIGH] == 0 || | ||||
954 | $value->[HIGH] > $self->[HIGH] ; | ||||
955 | |||||
956 | $self->[HIGH] -= $value->[HIGH] ; | ||||
957 | } | ||||
958 | |||||
959 | $value = $value->[LOW] ; | ||||
960 | } | ||||
961 | |||||
962 | if ($value > $self->[LOW]) { | ||||
963 | -- $self->[HIGH] ; | ||||
964 | $self->[LOW] = MAX32 - $value + $self->[LOW] + 1 ; | ||||
965 | } | ||||
966 | else { | ||||
967 | $self->[LOW] -= $value; | ||||
968 | } | ||||
969 | } | ||||
970 | |||||
971 | sub equal | ||||
972 | { | ||||
973 | my $self = shift; | ||||
974 | my $other = shift; | ||||
975 | |||||
976 | return $self->[LOW] == $other->[LOW] && | ||||
977 | $self->[HIGH] == $other->[HIGH] ; | ||||
978 | } | ||||
979 | |||||
980 | sub gt | ||||
981 | { | ||||
982 | my $self = shift; | ||||
983 | my $other = shift; | ||||
984 | |||||
985 | return $self->cmp($other) > 0 ; | ||||
986 | } | ||||
987 | |||||
988 | sub cmp | ||||
989 | { | ||||
990 | my $self = shift; | ||||
991 | my $other = shift ; | ||||
992 | |||||
993 | if ($self->[LOW] == $other->[LOW]) { | ||||
994 | return $self->[HIGH] - $other->[HIGH] ; | ||||
995 | } | ||||
996 | else { | ||||
997 | return $self->[LOW] - $other->[LOW] ; | ||||
998 | } | ||||
999 | } | ||||
1000 | |||||
1001 | |||||
1002 | sub is64bit | ||||
1003 | { | ||||
1004 | return $_[0]->[HIGH] > 0 ; | ||||
1005 | } | ||||
1006 | |||||
1007 | sub isAlmost64bit | ||||
1008 | { | ||||
1009 | return $_[0]->[HIGH] > 0 || $_[0]->[LOW] == MAX32 ; | ||||
1010 | } | ||||
1011 | |||||
1012 | sub getPacked_V64 | ||||
1013 | { | ||||
1014 | return pack "V V", @{ $_[0] } ; | ||||
1015 | } | ||||
1016 | |||||
1017 | sub getPacked_V32 | ||||
1018 | { | ||||
1019 | return pack "V", $_[0]->[LOW] ; | ||||
1020 | } | ||||
1021 | |||||
1022 | sub pack_V64 | ||||
1023 | { | ||||
1024 | return pack "V V", $_[0], 0; | ||||
1025 | } | ||||
1026 | |||||
1027 | |||||
1028 | sub full32 | ||||
1029 | { | ||||
1030 | return $_[0] == MAX32 ; | ||||
1031 | } | ||||
1032 | |||||
1033 | sub Value_VV64 | ||||
1034 | { | ||||
1035 | my $buffer = shift; | ||||
1036 | |||||
1037 | my ($lo, $hi) = unpack ("V V" , $buffer); | ||||
1038 | 2 | 108µs | 2 | 45µs | # spent 29µs (13+16) within U64::BEGIN@1038 which was called:
# once (13µs+16µs) by Compress::Zlib::BEGIN@10 at line 1038 # spent 29µs making 1 call to U64::BEGIN@1038
# spent 16µs making 1 call to warnings::unimport |
1039 | return $hi * HI_1 + $lo; | ||||
1040 | } | ||||
1041 | |||||
1042 | |||||
1043 | package IO::Compress::Base::Common; | ||||
1044 | |||||
1045 | 1 | 13µs | 1; | ||
# spent 7µs within IO::Compress::Base::Common::CORE:binmode which was called 3 times, avg 2µs/call:
# 3 times (7µs+0s) by IO::Compress::Base::Common::setBinModeInput at line 100, avg 2µs/call | |||||
# spent 37µs within IO::Compress::Base::Common::CORE:match which was called 12 times, avg 3µs/call:
# 12 times (37µs+0s) by IO::Compress::Base::Parameters::_checkType at line 751, avg 3µs/call | |||||
# spent 18µs within IO::Compress::Base::Common::CORE:subst which was called 15 times, avg 1µs/call:
# 15 times (18µs+0s) by IO::Compress::Base::Parameters::parse at line 652, avg 1µs/call |