Bug 4305 Improve code flow

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@gmail.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
(cherry picked from commit c95b5153e0)

Signed-off-by: Chris Nighswonger <chris.nighswonger@gmail.com>
This commit is contained in:
Colin Campbell 2010-11-11 09:02:13 -05:00 committed by Chris Nighswonger
parent 7b7ee3303d
commit c82169bc32
1 changed files with 9 additions and 8 deletions

View File

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