← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/share/koha/opac/cgi-bin/opac/opac-search.pl
  Run on Tue Oct 15 17:10:45 2013
Reported on Tue Oct 15 17:11:25 2013

Filename/usr/share/perl5/MARC/Record.pm
StatementsExecuted 28081 statements in 104ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
47112557.8ms96.8msMARC::Record::::fieldMARC::Record::field
7840218.41ms8.41msMARC::Record::::CORE:regcompMARC::Record::CORE:regcomp (opcode)
1131317.54ms9.46msMARC::Record::::_all_parms_are_fieldsMARC::Record::_all_parms_are_fields
1081537.24ms16.4msMARC::Record::::append_fieldsMARC::Record::append_fields
7827116.22ms6.22msMARC::Record::::CORE:matchMARC::Record::CORE:match (opcode)
596653.57ms3.57msMARC::Record::::fieldsMARC::Record::fields
544113.57ms5.37msMARC::Record::::encodingMARC::Record::encoding
694752.87ms2.87msMARC::Record::::leaderMARC::Record::leader
25112.67ms4.87msMARC::Record::::insert_fields_orderedMARC::Record::insert_fields_ordered
1112.06ms2.30msMARC::Record::::BEGIN@14MARC::Record::BEGIN@14
1861221.71ms28.1msMARC::Record::::subfieldMARC::Record::subfield
75331.10ms1.10msMARC::Record::::newMARC::Record::new
2511615µs809µsMARC::Record::::delete_fieldsMARC::Record::delete_fields
2511155µs964µsMARC::Record::::delete_fieldMARC::Record::delete_field
131159µs59µsMARC::Record::::CORE:qrMARC::Record::CORE:qr (opcode)
11123µs71µsMARC::Record::::BEGIN@23MARC::Record::BEGIN@23
11117µs20µsMARC::Record::::BEGIN@9MARC::Record::BEGIN@9
11115µs87µsMARC::Record::::BEGIN@34MARC::Record::BEGIN@34
11114µs39µsMARC::Record::::BEGIN@26MARC::Record::BEGIN@26
11114µs62µsMARC::Record::::BEGIN@15MARC::Record::BEGIN@15
11112µs15µsMARC::Record::::BEGIN@10MARC::Record::BEGIN@10
11110µs38µsMARC::Record::::BEGIN@32MARC::Record::BEGIN@32
1119µs127µsMARC::Record::::BEGIN@27MARC::Record::BEGIN@27
1118µs33µsMARC::Record::::BEGIN@12MARC::Record::BEGIN@12
0000s0sMARC::Record::::_gripeMARC::Record::_gripe
0000s0sMARC::Record::::_warnMARC::Record::_warn
0000s0sMARC::Record::::add_fieldsMARC::Record::add_fields
0000s0sMARC::Record::::as_formattedMARC::Record::as_formatted
0000s0sMARC::Record::::as_usmarcMARC::Record::as_usmarc
0000s0sMARC::Record::::authorMARC::Record::author
0000s0sMARC::Record::::cloneMARC::Record::clone
0000s0sMARC::Record::::editionMARC::Record::edition
0000s0sMARC::Record::::insert_fields_afterMARC::Record::insert_fields_after
0000s0sMARC::Record::::insert_fields_beforeMARC::Record::insert_fields_before
0000s0sMARC::Record::::insert_grouped_fieldMARC::Record::insert_grouped_field
0000s0sMARC::Record::::new_from_usmarcMARC::Record::new_from_usmarc
0000s0sMARC::Record::::publication_dateMARC::Record::publication_date
0000s0sMARC::Record::::set_leader_lengthsMARC::Record::set_leader_lengths
0000s0sMARC::Record::::titleMARC::Record::title
0000s0sMARC::Record::::title_properMARC::Record::title_proper
0000s0sMARC::Record::::warningsMARC::Record::warnings
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package MARC::Record;
2
3=head1 NAME
4
- -
9329µs224µs
# spent 20µs (17+4) within MARC::Record::BEGIN@9 which was called: # once (17µs+4µs) by C4::Biblio::BEGIN@27 at line 9
use strict;
# spent 20µs making 1 call to MARC::Record::BEGIN@9 # spent 4µs making 1 call to strict::import
10342µs219µs
# spent 15µs (12+3) within MARC::Record::BEGIN@10 which was called: # once (12µs+3µs) by C4::Biblio::BEGIN@27 at line 10
use integer;
# spent 15µs making 1 call to MARC::Record::BEGIN@10 # spent 3µs making 1 call to integer::import
11
12328µs258µs
# spent 33µs (8+25) within MARC::Record::BEGIN@12 which was called: # once (8µs+25µs) by C4::Biblio::BEGIN@27 at line 12
use vars qw( $ERROR );
# spent 33µs making 1 call to MARC::Record::BEGIN@12 # spent 25µs making 1 call to vars::import
13
143127µs22.31ms
# spent 2.30ms (2.06+239µs) within MARC::Record::BEGIN@14 which was called: # once (2.06ms+239µs) by C4::Biblio::BEGIN@27 at line 14
use MARC::Field;
# spent 2.30ms making 1 call to MARC::Record::BEGIN@14 # spent 5µs making 1 call to UNIVERSAL::import
15380µs2111µs
# spent 62µs (14+49) within MARC::Record::BEGIN@15 which was called: # once (14µs+49µs) by C4::Biblio::BEGIN@27 at line 15
use Carp qw(croak);
# spent 62µs making 1 call to MARC::Record::BEGIN@15 # spent 48µs making 1 call to Exporter::import
16
17=head1 VERSION
18
- -
23351µs2119µs
# spent 71µs (23+48) within MARC::Record::BEGIN@23 which was called: # once (23µs+48µs) by C4::Biblio::BEGIN@27 at line 23
use vars qw( $VERSION );
# spent 71µs making 1 call to MARC::Record::BEGIN@23 # spent 48µs making 1 call to vars::import
241700ns$VERSION = '2.0.2';
25
26335µs263µs
# spent 39µs (14+24) within MARC::Record::BEGIN@26 which was called: # once (14µs+24µs) by C4::Biblio::BEGIN@27 at line 26
use Exporter;
# spent 39µs making 1 call to MARC::Record::BEGIN@26 # spent 24µs making 1 call to Exporter::import
27363µs2244µs
# spent 127µs (9+117) within MARC::Record::BEGIN@27 which was called: # once (9µs+117µs) by C4::Biblio::BEGIN@27 at line 27
use vars qw( @ISA @EXPORTS @EXPORT_OK );
# spent 127µs making 1 call to MARC::Record::BEGIN@27 # spent 117µs making 1 call to vars::import
28113µs@ISA = qw( Exporter );
291400ns@EXPORTS = qw();
301700ns@EXPORT_OK = qw( LEADER_LEN );
31
32450µs265µs
# spent 38µs (10+28) within MARC::Record::BEGIN@32 which was called: # once (10µs+28µs) by C4::Biblio::BEGIN@27 at line 32
use vars qw( $DEBUG ); $DEBUG = 0;
# spent 38µs making 1 call to MARC::Record::BEGIN@32 # spent 28µs making 1 call to vars::import
33
3431.99ms2160µs
# spent 87µs (15+72) within MARC::Record::BEGIN@34 which was called: # once (15µs+72µs) by C4::Biblio::BEGIN@27 at line 34
use constant LEADER_LEN => 24;
# spent 87µs making 1 call to MARC::Record::BEGIN@34 # spent 72µs making 1 call to constant::import
35
36=head1 DESCRIPTION
37
- -
56
# spent 1.10ms within MARC::Record::new which was called 75 times, avg 15µs/call: # 25 times (460µs+0s) by MARC::File::USMARC::decode at line 119 of MARC/File/USMARC.pm, avg 18µs/call # 25 times (402µs+0s) by C4::Biblio::GetMarcBiblio at line 1260 of /usr/share/koha/lib/C4/Biblio.pm, avg 16µs/call # 25 times (239µs+0s) by MARC::File::SAX::start_element at line 51 of MARC/File/SAX.pm, avg 10µs/call
sub new {
572251.21ms my $class = shift;
58 my $self = {
59 _leader => ' ' x 24,
60 _fields => [],
61 _warnings => [],
62 };
63 return bless $self, $class;
64} # new()
65
66=head2 new_from_usmarc( $marcblob [, \&filter_func($tagno,$tagdata)] )
67
- -
75sub new_from_usmarc {
76 my $blob = shift;
77 $blob = shift if (ref($blob) || ($blob eq "MARC::Record"));
78
79 require MARC::File::USMARC;
80
81 return MARC::File::USMARC::decode( $blob, @_ );
82}
83
84=head1 COMMON FIELD RETRIEVAL METHODS
85
- -
104sub title() {
105 my $self = shift;
106
107 my $field = $self->field(245);
108 return $field ? $field->as_string : "";
109}
110
111=head2 title_proper()
112
- -
117sub title_proper() {
118 my $self = shift;
119
120 my $field = $self->field(245);
121
122 if ( $field ) {
123 return $field->as_string('anp');
124 } else {
125 return "";
126 }
127}
128
129=head2 author()
130
- -
135sub author() {
136 my $self = shift;
137
138 my $field = $self->field('100|110|111');
139 return $field ? $field->as_string : "";
140}
141
142=head2 edition()
143
- -
148sub edition() {
149 my $self = shift;
150
151 my $str = $self->subfield(250,'a');
152 return defined $str ? $str : "";
153}
154
155=head2 publication_date()
156
- -
161sub publication_date() {
162 my $self = shift;
163
164 my $str = $self->subfield(260,'c');
165 return defined $str ? $str : "";
166}
167
168=head1 FIELD & SUBFIELD ACCESS METHODS
169
- -
177
# spent 3.57ms within MARC::Record::fields which was called 596 times, avg 6µs/call: # 471 times (2.26ms+0s) by MARC::Record::field at line 209, avg 5µs/call # 25 times (435µs+0s) by C4::XSLT::transformMARCXML4XSLT at line 82 of /usr/share/koha/lib/C4/XSLT.pm, avg 17µs/call # 25 times (299µs+0s) by MARC::File::XML::record at line 344 of MARC/File/XML.pm, avg 12µs/call # 25 times (227µs+0s) by C4::Biblio::TransformMarcToKoha at line 2510 of /usr/share/koha/lib/C4/Biblio.pm, avg 9µs/call # 25 times (180µs+0s) by C4::Charset::SetUTF8Flag at line 136 of /usr/share/koha/lib/C4/Charset.pm, avg 7µs/call # 25 times (176µs+0s) by C4::Charset::SetUTF8Flag at line 135 of /usr/share/koha/lib/C4/Charset.pm, avg 7µs/call
sub fields() {
17811924.70ms my $self = shift;
179 return @{$self->{_fields}};
180}
181
182=head2 field( I<tagspec(s)> )
183
- -
1931400nsmy %field_regex;
194
195
# spent 96.8ms (57.8+38.9) within MARC::Record::field which was called 471 times, avg 205µs/call: # 186 times (14.2ms+9.82ms) by MARC::Record::subfield at line 238, avg 129µs/call # 50 times (9.39ms+6.46ms) by C4::XSLT::transformMARCXML4XSLT at line 87 of /usr/share/koha/lib/C4/XSLT.pm, avg 317µs/call # 34 times (3.16ms+2.05ms) by C4::Biblio::GetCOinSBiblio at line 1402 of /usr/share/koha/lib/C4/Biblio.pm, avg 153µs/call # 25 times (4.38ms+3.35ms) by C4::Koha::GetNormalizedUPC at line 1309 of /usr/share/koha/lib/C4/Koha.pm, avg 309µs/call # 25 times (4.30ms+2.85ms) by C4::Search::searchResults at line 1786 of /usr/share/koha/lib/C4/Search.pm, avg 286µs/call # 25 times (4.25ms+2.75ms) by C4::Search::searchResults at line 1777 of /usr/share/koha/lib/C4/Search.pm, avg 280µs/call # 25 times (4.21ms+2.54ms) by C4::Koha::GetNormalizedEAN at line 1371 of /usr/share/koha/lib/C4/Koha.pm, avg 270µs/call # 25 times (3.94ms+2.56ms) by C4::Koha::GetNormalizedISBN at line 1345 of /usr/share/koha/lib/C4/Koha.pm, avg 260µs/call # 25 times (4.03ms+2.41ms) by C4::Koha::GetNormalizedOCLCNumber at line 1389 of /usr/share/koha/lib/C4/Koha.pm, avg 258µs/call # 25 times (3.48ms+2.37ms) by C4::Biblio::_koha_marc_update_bib_ids at line 2861 of /usr/share/koha/lib/C4/Biblio.pm, avg 234µs/call # 25 times (2.35ms+1.66ms) by C4::Biblio::GetCOinSBiblio at line 1397 of /usr/share/koha/lib/C4/Biblio.pm, avg 160µs/call # once (136µs+107µs) by C4::Biblio::GetCOinSBiblio at line 1411 of /usr/share/koha/lib/C4/Biblio.pm
sub field {
1961210766.3ms my $self = shift;
197 my @specs = @_;
198
199 my @list = ();
200 for my $tag ( @specs ) {
201 my $regex = $field_regex{ $tag };
202
203 # Compile & stash it if necessary
204 if ( not defined $regex ) {
20526236µs $regex = qr/^$tag$/;
# spent 177µs making 13 calls to MARC::Record::CORE:regcomp, avg 14µs/call # spent 59µs making 13 calls to MARC::Record::CORE:qr, avg 5µs/call
206 $field_regex{ $tag } = $regex;
207 } # not defined
208
2094712.26ms for my $maybe ( $self->fields ) {
# spent 2.26ms making 471 calls to MARC::Record::fields, avg 5µs/call
2102348136.4ms if ( $maybe->tag =~ $regex ) {
# spent 22.0ms making 7827 calls to MARC::Field::tag, avg 3µs/call # spent 8.24ms making 7827 calls to MARC::Record::CORE:regcomp, avg 1µs/call # spent 6.22ms making 7827 calls to MARC::Record::CORE:match, avg 795ns/call
211 return $maybe unless wantarray;
212
213 push( @list, $maybe );
214 } # if
215 } # for $maybe
216 } # for $tag
217
218 return unless wantarray;
219 return @list;
220}
221
222=head2 subfield( $tag, $subfield )
223
- -
233
# spent 28.1ms (1.71+26.4) within MARC::Record::subfield which was called 186 times, avg 151µs/call: # 25 times (385µs+6.93ms) by C4::Search::searchResults at line 1702 of /usr/share/koha/lib/C4/Search.pm, avg 293µs/call # 25 times (240µs+2.02ms) by C4::Biblio::GetCOinSBiblio at line 1407 of /usr/share/koha/lib/C4/Biblio.pm, avg 90µs/call # 25 times (228µs+1.92ms) by C4::Biblio::GetCOinSBiblio at line 1408 of /usr/share/koha/lib/C4/Biblio.pm, avg 86µs/call # 24 times (110µs+5.41ms) by C4::Biblio::GetCOinSBiblio at line 1429 of /usr/share/koha/lib/C4/Biblio.pm, avg 230µs/call # 24 times (143µs+4.25ms) by C4::Biblio::GetCOinSBiblio at line 1430 of /usr/share/koha/lib/C4/Biblio.pm, avg 183µs/call # 24 times (195µs+2.22ms) by C4::Biblio::GetCOinSBiblio at line 1427 of /usr/share/koha/lib/C4/Biblio.pm, avg 101µs/call # 24 times (256µs+2.14ms) by C4::Biblio::GetCOinSBiblio at line 1428 of /usr/share/koha/lib/C4/Biblio.pm, avg 100µs/call # 11 times (128µs+790µs) by C4::Biblio::GetCOinSBiblio at line 1397 of /usr/share/koha/lib/C4/Biblio.pm, avg 83µs/call # once (7µs+217µs) by C4::Biblio::GetCOinSBiblio at line 1420 of /usr/share/koha/lib/C4/Biblio.pm # once (8µs+180µs) by C4::Biblio::GetCOinSBiblio at line 1413 of /usr/share/koha/lib/C4/Biblio.pm # once (7µs+179µs) by C4::Biblio::GetCOinSBiblio at line 1415 of /usr/share/koha/lib/C4/Biblio.pm # once (7µs+179µs) by C4::Biblio::GetCOinSBiblio at line 1414 of /usr/share/koha/lib/C4/Biblio.pm
sub subfield {
2348891.67ms my $self = shift;
235 my $tag = shift;
236 my $subfield = shift;
237
23818624.0ms my $field = $self->field($tag) or return;
# spent 24.0ms making 186 calls to MARC::Record::field, avg 129µs/call
2391452.40ms return $field->subfield($subfield);
# spent 2.40ms making 145 calls to MARC::Field::subfield, avg 17µs/call
240} # subfield()
241
242=for internal
243
- -
246
# spent 9.46ms (7.54+1.91) within MARC::Record::_all_parms_are_fields which was called 1131 times, avg 8µs/call: # 1081 times (7.26ms+1.85ms) by MARC::Record::append_fields at line 268, avg 8µs/call # 25 times (153µs+42µs) by MARC::Record::delete_fields at line 438, avg 8µs/call # 25 times (125µs+27µs) by MARC::Record::insert_fields_ordered at line 358, avg 6µs/call
sub _all_parms_are_fields {
247339310.4ms for ( @_ ) {
24811311.91ms return 0 unless UNIVERSAL::isa($_, 'MARC::Field');
# spent 1.91ms making 1131 calls to UNIVERSAL::isa, avg 2µs/call
249 }
250 return 1;
251}
252
253=head2 append_fields( @fields )
254
- -
265
# spent 16.4ms (7.24+9.11) within MARC::Record::append_fields which was called 1081 times, avg 15µs/call: # 512 times (3.39ms+4.17ms) by MARC::File::USMARC::decode at line 226 of MARC/File/USMARC.pm, avg 15µs/call # 480 times (3.06ms+3.94ms) by MARC::File::SAX::end_element at line 92 of MARC/File/SAX.pm, avg 15µs/call # 32 times (381µs+431µs) by MARC::File::USMARC::decode at line 192 of MARC/File/USMARC.pm, avg 25µs/call # 32 times (277µs+408µs) by MARC::File::SAX::end_element at line 83 of MARC/File/SAX.pm, avg 21µs/call # 25 times (131µs+162µs) by MARC::Record::insert_fields_ordered at line 374, avg 12µs/call
sub append_fields {
26643246.94ms my $self = shift;
267
26810819.11ms _all_parms_are_fields(@_) or croak('Arguments must be MARC::Field objects');
# spent 9.11ms making 1081 calls to MARC::Record::_all_parms_are_fields, avg 8µs/call
269
270 push(@{ $self->{_fields} }, @_);
271 return scalar @_;
272}
273
274=head2 insert_fields_before( $before_field, @new_fields )
275
- -
287sub insert_fields_before {
288 my $self = shift;
289
290 _all_parms_are_fields(@_)
291 or croak('All arguments must be MARC::Field objects');
292
293 my ($before,@new) = @_;
294
295 ## find position of $before
296 my $fields = $self->{_fields};
297 my $pos = 0;
298 foreach my $f (@$fields) {
299 last if ($f == $before);
300 $pos++;
301 }
302
303 ## insert before $before
304 if ($pos >= @$fields) {
305 $self->_warn("Couldn't find field to insert before");
306 return;
307 }
308 splice(@$fields,$pos,0,@new);
309 return scalar @new;
310
311}
312
313=head2 insert_fields_after( $after_field, @new_fields )
314
- -
321sub insert_fields_after {
322 my $self = shift;
323
324 _all_parms_are_fields(@_) or croak('All arguments must be MARC::Field objects');
325 my ($after,@new) = @_;
326
327 ## find position of $after
328 my $fields = $self->{_fields};
329 my $pos = 0;
330 my $found = 0;
331 foreach my $f (@$fields) {
332 if ($f == $after) {
333 $found = 1;
334 last;
335 }
336 $pos++;
337 }
338
339 ## insert after $after
340 unless ($found) {
341 $self->_warn("Couldn't find field to insert after");
342 return;
343 }
344 splice(@$fields,$pos+1,0,@new);
345 return scalar @new;
346}
347
348=head2 insert_fields_ordered( @new_fields )
349
- -
355
# spent 4.87ms (2.67+2.20) within MARC::Record::insert_fields_ordered which was called 25 times, avg 195µs/call: # 25 times (2.67ms+2.20ms) by C4::Biblio::_koha_marc_update_bib_ids at line 2863 of /usr/share/koha/lib/C4/Biblio.pm, avg 195µs/call
sub insert_fields_ordered {
3566371.91ms my ( $self, @new ) = @_;
357
35825151µs _all_parms_are_fields(@new)
# spent 151µs making 25 calls to MARC::Record::_all_parms_are_fields, avg 6µs/call
359 or croak('All arguments must be MARC::Field objects');
360
361 ## go through each new field
362 NEW_FIELD: foreach my $newField ( @new ) {
363
364 ## find location before which it should be inserted
365 EXISTING_FIELD: foreach my $field ( @{ $self->{_fields} } ) {
3669741.75ms if ( $field->tag() >= $newField->tag() ) {
# spent 1.75ms making 974 calls to MARC::Field::tag, avg 2µs/call
367 $self->insert_fields_before( $field, $newField );
368 next NEW_FIELD;
369 }
370 }
371
372 ## if we fell through then this new field is higher than
373 ## all the existing fields, so we append.
37425292µs $self->append_fields( $newField );
# spent 292µs making 25 calls to MARC::Record::append_fields, avg 12µs/call
375
376 }
377 return( scalar( @new ) );
378}
379
380=head2 insert_grouped_field( $field )
381
- -
398sub insert_grouped_field {
399 my ($self,$new) = @_;
400 _all_parms_are_fields($new) or croak('Argument must be MARC::Field object');
401
402 ## try to find the end of the field group and insert it there
403 my $limit = int($new->tag() / 100);
404 my $found = 0;
405 foreach my $field ($self->fields()) {
406 if ( int($field->tag() / 100) > $limit ) {
407 $self->insert_fields_before($field,$new);
408 $found = 1;
409 last;
410 }
411 }
412
413 ## if we couldn't find the end of the group, then we must not have
414 ## any tags this high yet, so just append it
415 if (!$found) {
416 $self->append_fields($new);
417 }
418
419 return(1);
420
421}
422
423
424=head2 delete_fields( $field )
425
- -
436
# spent 809µs (615+195) within MARC::Record::delete_fields which was called 25 times, avg 32µs/call: # 25 times (615µs+195µs) by MARC::Record::delete_field at line 458, avg 32µs/call
sub delete_fields {
437200612µs my $self = shift;
43825195µs _all_parms_are_fields(@_) or croak('Arguments must be MARC::Field object');
# spent 195µs making 25 calls to MARC::Record::_all_parms_are_fields, avg 8µs/call
439 my @fields = @{$self->{_fields}};
440 my $original_count = @fields;
441
442 foreach my $deleter (@_) {
443 @fields = grep { $_ != $deleter } @fields;
444 }
445 $self->{_fields} = \@fields;
446
447 return $original_count - @fields;
448}
449
450=head2 delete_field()
451
- -
457
# spent 964µs (155+810) within MARC::Record::delete_field which was called 25 times, avg 39µs/call: # 25 times (155µs+810µs) by C4::Biblio::_koha_marc_update_bib_ids at line 2862 of /usr/share/koha/lib/C4/Biblio.pm, avg 39µs/call
sub delete_field {
45825144µs25809µs return delete_fields(@_);
# spent 809µs making 25 calls to MARC::Record::delete_fields, avg 32µs/call
459}
460
461=head2 as_usmarc()
462
- -
468sub as_usmarc() {
469 my $self = shift;
470
471 require MARC::File::USMARC;
472
473 return MARC::File::USMARC::encode( $self );
474}
475
476=head2 as_formatted()
477
- -
482sub as_formatted() {
483 my $self = shift;
484
485 my @lines = ( "LDR " . ($self->{_leader} || "") );
486 for my $field ( @{$self->{_fields}} ) {
487 push( @lines, $field->as_formatted() );
488 }
489
490 return join( "\n", @lines );
491} # as_formatted
492
493
494=head2 leader()
495
- -
501
# spent 2.87ms within MARC::Record::leader which was called 694 times, avg 4µs/call: # 544 times (1.79ms+0s) by MARC::Record::encoding at line 538, avg 3µs/call # 25 times (286µs+0s) by MARC::File::USMARC::decode at line 133 of MARC/File/USMARC.pm, avg 11µs/call # 25 times (231µs+0s) by MARC::File::SAX::end_element at line 108 of MARC/File/SAX.pm, avg 9µs/call # 25 times (209µs+0s) by C4::Biblio::GetCOinSBiblio at line 1309 of /usr/share/koha/lib/C4/Biblio.pm, avg 8µs/call # 25 times (207µs+0s) by MARC::File::XML::record at line 316 of MARC/File/XML.pm, avg 8µs/call # 25 times (79µs+0s) by MARC::File::XML::record at line 342 of MARC/File/XML.pm, avg 3µs/call # 25 times (65µs+0s) by C4::Biblio::GetCOinSBiblio at line 1310 of /usr/share/koha/lib/C4/Biblio.pm, avg 3µs/call
sub leader {
50228763.70ms my $self = shift;
503 my $text = shift;
504
505 if ( defined $text ) {
506 (length($text) eq 24)
507 or $self->_warn( "Leader must be 24 bytes long" );
508 $self->{_leader} = $text;
509 } # set the leader
510
511 return $self->{_leader};
512} # leader()
513
514=head2 encoding()
515
- -
535
# spent 5.37ms (3.57+1.79) within MARC::Record::encoding which was called 544 times, avg 10µs/call: # 544 times (3.57ms+1.79ms) by MARC::File::USMARC::decode at line 171 of MARC/File/USMARC.pm, avg 10µs/call
sub encoding {
53621763.36ms my ($self,$arg) = @_;
537 # we basically report from and modify the leader directly
5385441.79ms my $leader = $self->leader();
# spent 1.79ms making 544 calls to MARC::Record::leader, avg 3µs/call
539
540 # when setting
541 if ( defined($arg) ) {
542 if ( $arg =~ /UTF-?8/i ) {
543 substr($leader,9,1) = 'a';
544 }
545 elsif ( $arg =~ /MARC-?8/i ) {
546 substr($leader,9,1) = ' ';
547 }
548 $self->leader($leader);
549 }
550
551 return substr($leader,9,1) eq 'a' ? 'UTF-8' : 'MARC-8';
552}
553
554=head2 set_leader_lengths( $reclen, $baseaddr )
555
- -
560sub set_leader_lengths {
561 my $self = shift;
562 my $reclen = shift;
563 my $baseaddr = shift;
564 if ($reclen > 99999) {
565 carp( "Record length of $reclen is larger than the MARC spec allows (99999 bytes)." );
566 }
567 substr($self->{_leader},0,5) = sprintf("%05d",$reclen);
568 substr($self->{_leader},12,5) = sprintf("%05d",$baseaddr);
569 # MARC21 defaults: http://www.loc.gov/marc/bibliographic/ecbdldrd.html
570 substr($self->{_leader},10,2) = '22';
571 substr($self->{_leader},20,4) = '4500';
572}
573
574=head2 clone()
575
- -
596sub clone {
597 my $self = shift;
598 my @keeper_tags = @_;
599
600 # create a new object of whatever type we happen to be
601 my $class = ref( $self );
602 my $clone = $class->new();
603
604 $clone->{_leader} = $self->{_leader};
605
606 my $filtered = @keeper_tags ? [$self->field( @keeper_tags )] : undef;
607
608 for my $field ( $self->fields() ) {
609 if ( !$filtered || (grep {$field eq $_} @$filtered ) ) {
610 $clone->append_fields( $field->clone );
611 }
612 }
613
614 # XXX FIX THIS $clone->update_leader();
615
616 return $clone;
617}
618
619=head2 warnings()
620
- -
635sub warnings() {
636 my $self = shift;
637 my @warnings = @{$self->{_warnings}};
638 $self->{_warnings} = [];
639 return @warnings;
640}
641
642=head2 add_fields()
643
- -
682sub add_fields {
683 my $self = shift;
684
685 my $nfields = 0;
686 my $fields = $self->{_fields};
687
688 while ( my $parm = shift ) {
689 # User handed us a list of data (most common possibility)
690 if ( ref($parm) eq "" ) {
691 my $field = MARC::Field->new( $parm, @_ )
692 or return _gripe( $MARC::Field::ERROR );
693 push( @$fields, $field );
694 ++$nfields;
695 last; # Bail out, we're done eating parms
696
697 # User handed us an object.
698 } elsif ( UNIVERSAL::isa($parm, 'MARC::Field') ) {
699 push( @$fields, $parm );
700 ++$nfields;
701
702 # User handed us an anonymous list of parms
703 } elsif ( ref($parm) eq "ARRAY" ) {
704 my $field = MARC::Field->new(@$parm)
705 or return _gripe( $MARC::Field::ERROR );
706 push( @$fields, $field );
707 ++$nfields;
708
709 } else {
710 croak( "Unknown parm of type", ref($parm), " passed to add_fields()" );
711 } # if
712
713 } # while
714
715 return $nfields;
716}
717
718# NOTE: _warn is an object method
719sub _warn {
720 my $self = shift;
721 push( @{$self->{_warnings}}, join( "", @_ ) );
722 return( $self );
723}
724
725
726# NOTE: _gripe is NOT an object method
727sub _gripe {
728 $ERROR = join( "", @_ );
729
730 warn $ERROR;
731
732 return;
733}
734
735
73616µs1;
737
738__END__
 
# spent 6.22ms within MARC::Record::CORE:match which was called 7827 times, avg 795ns/call: # 7827 times (6.22ms+0s) by MARC::Record::field at line 210, avg 795ns/call
sub MARC::Record::CORE:match; # opcode
# spent 59µs within MARC::Record::CORE:qr which was called 13 times, avg 5µs/call: # 13 times (59µs+0s) by MARC::Record::field at line 205, avg 5µs/call
sub MARC::Record::CORE:qr; # opcode
# spent 8.41ms within MARC::Record::CORE:regcomp which was called 7840 times, avg 1µs/call: # 7827 times (8.24ms+0s) by MARC::Record::field at line 210, avg 1µs/call # 13 times (177µs+0s) by MARC::Record::field at line 205, avg 14µs/call
sub MARC::Record::CORE:regcomp; # opcode