[libcatmandu-marc-perl] 37/208: benchmark

Jonas Smedegaard dr at jones.dk
Sat Oct 28 03:42:33 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 17aed88f057339185ecd6a076a3ef7a979fa0197
Author: Patrick Hochstenbach <patrick.hochstenbach at ugent.be>
Date:   Wed Jul 13 11:47:21 2016 +0200

    benchmark
---
 lib/Catmandu/Fix/Inline/marc_map.pm |  8 +++++++-
 lib/Catmandu/MARC.pm                | 15 +++++----------
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/lib/Catmandu/Fix/Inline/marc_map.pm b/lib/Catmandu/Fix/Inline/marc_map.pm
index 357e6d4..fa16b51 100644
--- a/lib/Catmandu/Fix/Inline/marc_map.pm
+++ b/lib/Catmandu/Fix/Inline/marc_map.pm
@@ -71,10 +71,16 @@ sub marc_map {
     my ($data,$marc_path,%opts) = @_;
     # Set default to nested_arrays for backwards compatibility
     $opts{'-nested_arrays'} = 1 unless exists $opts{'-nested_arrays'};
-    return Catmandu::MARC->instance->marc_map(
+    my $vals = Catmandu::MARC->instance->marc_map(
                 $data,
                 $marc_path,
                 \%opts);
+    if (wantarray) {
+        defined($vals) && ref($vals) eq 'ARRAY' ? @$vals : ($vals);
+    }
+    else {
+        $vals;
+    }
 }
 
 1;
diff --git a/lib/Catmandu/MARC.pm b/lib/Catmandu/MARC.pm
index d74ae2d..22fe9f0 100644
--- a/lib/Catmandu/MARC.pm
+++ b/lib/Catmandu/MARC.pm
@@ -40,11 +40,11 @@ sub marc_map {
         next if (
             ($context->{is_regex_field} == 0 && $field->[0] ne $context->{field} )
             ||
-            ($context->{is_regex_field} == 1 && $field->[0] !~ $context->{field_regex} )
-            ||
             (defined $context->{ind1} && (!defined $field->[1] || $field->[1] ne $context->{ind1}))
             ||
             (defined $context->{ind2} && (!defined $field->[2] || $field->[2] ne $context->{ind2}))
+            ||
+            ($context->{is_regex_field} == 1 && $field->[0] !~ $context->{field_regex} )
         );
 
         my $v;
@@ -136,12 +136,7 @@ sub marc_map {
         }
     }
 
-    if (wantarray) {
-        defined($vals) && ref($vals) eq 'ARRAY' ? @$vals : ($vals);
-    }
-    else {
-        $vals;
-    }
+    $vals;
 }
 
 sub marc_add {
@@ -465,7 +460,7 @@ sub compile_marc_path {
             $subfield = '[a-z0-9_]';
         }
         if (defined($subfield)) {
-            $subfield_regex = qr/^${subfield}$/;
+            $subfield_regex = qr/^(?:${subfield})$/;
         }
         $from           = $7;
         $to             = $9;
@@ -477,7 +472,7 @@ sub compile_marc_path {
 
     if ($field =~ /\*/) {
         $field_regex    = $field;
-        $field_regex    =~ s/\*/./g;
+        $field_regex    =~ s/\*/(?:[A-Z0-9])/g;
         $is_regex_field = 1;
         $field_regex    = qr/^$field_regex$/;
     }

-- 
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