[Koha-patches] [PATCH 2/2] [SIGNED-OFF] Bug 4305 Improve code flow
Galen Charlton
gmcharlt at gmail.com
Thu Nov 11 15:02:13 CET 2010
From: Colin Campbell <colin.campbell at ptfs-europe.com>
Use the ISBN Object's method to format the string
rather than add extra code to do it
Clean up the code flow for clarity
Benchmarking shows its a bit faster too
Don't add to the number of Test::Perl::Critic warnings
for no benefit
Signed-off-by: Galen Charlton <gmcharlt at gmail.com>
---
C4/Koha.pm | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/C4/Koha.pm b/C4/Koha.pm
index e746f83..a63a3a5 100644
--- a/C4/Koha.pm
+++ b/C4/Koha.pm
@@ -1350,14 +1350,15 @@ sub _normalize_match_point {
return $normalized_match_point;
}
-sub _isbn_cleanup ($) {
- my $isbn = Business::ISBN->new( shift );
- return undef unless $isbn;
- $isbn = $isbn->as_isbn10 if $isbn->type eq 'ISBN13';
- return undef unless $isbn;
- $isbn = $isbn->as_string;
- $isbn =~ s/-//g;
- return $isbn;
+sub _isbn_cleanup {
+ my $isbn = Business::ISBN->new( $_[0] );
+ if ( $isbn ) {
+ $isbn = $isbn->as_isbn10 if $isbn->type eq 'ISBN13';
+ if (defined $isbn) {
+ return $isbn->as_string([]);
+ }
+ }
+ return;
}
1;
--
1.7.0
More information about the Koha-patches
mailing list