[libcatmandu-marc-perl] 32/208: Benchmarking
Jonas Smedegaard
dr at jones.dk
Sat Oct 28 03:42:32 UTC 2017
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag upstream/1.19
in repository libcatmandu-marc-perl.
commit d170ae18ea5ef6a2150b4deb316e42987e6e7138
Author: Patrick Hochstenbach <patrick.hochstenbach at ugent.be>
Date: Fri Jul 8 14:55:26 2016 +0200
Benchmarking
---
lib/Catmandu/MARC.pm | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/lib/Catmandu/MARC.pm b/lib/Catmandu/MARC.pm
index aa69dd7..5f4a817 100644
--- a/lib/Catmandu/MARC.pm
+++ b/lib/Catmandu/MARC.pm
@@ -24,7 +24,7 @@ sub marc_map {
my $split = $opts->{'-split'} // 0;
my $join_char = $opts->{'-join'} // '';
- my $pluck = $opts->{'-pluck'};
+ my $pluck = $opts->{'-pluck'} // 0;
my $value_set = $opts->{'-value'};
my $nested_arrays = $opts->{'-nested_arrays'} // 0;
@@ -57,7 +57,7 @@ sub marc_map {
}
}
else {
- $v = _extract_subfields($field,$context, pluck => $pluck);
+ $v = _extract_subfields($field, $context, { pluck => $pluck });
if (defined $v && @$v) {
if (!$split) {
@@ -122,15 +122,16 @@ sub marc_map {
}
sub _extract_subfields {
- my ($field,$context,%opts) = @_;
- my $field_size = int(@$field);
+ my $field = $_[0];
+ my $context = $_[1];
+ my $opts = $_[2];
my @v = ();
- if ($opts{pluck}) {
+ if ($opts->{pluck}) {
# Treat the subfield as a hash index
my $_h = {};
- for (my $i = $context->{start}; $i < $field_size; $i += 2) {
+ for (my $i = $context->{start}; $field->[$i]; $i += 2) {
push @{ $_h->{ $field->[$i] } } , $field->[$i + 1];
}
my $subfield = $context->{subfield};
@@ -140,7 +141,7 @@ sub _extract_subfields {
}
}
else {
- for (my $i = $context->{start}; $i < $field_size; $i += 2) {
+ for (my $i = $context->{start}; $field->[$i]; $i += 2) {
my $subfield_regex = $context->{subfield_regex};
if ($field->[$i] =~ $subfield_regex) {
push(@v, $field->[$i + 1]);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcatmandu-marc-perl.git
More information about the Pkg-perl-cvs-commits
mailing list