Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added Algorithm::Diff::XS support

  • Loading branch information...
commit 76a486c6abcd5cd318db5628b289d3c7bddab6cc 1 parent e8d86e4
@typester authored
Showing with 25 additions and 6 deletions.
  1. +4 −0 MANIFEST
  2. +6 −0 Makefile.PL
  3. +15 −2 lib/Array/Diff.pm
  4. +0 −4 t/00_compile.t
View
4 MANIFEST
@@ -21,6 +21,10 @@ Makefile.PL
MANIFEST This list of files
META.yml
README
+t/001_load.t
+t/002_pod.t
+t/003_podcoverage.t
+t/004_diff.t
t/00_compile.t
t/pod.t
t/pod_coverage.t
View
6 Makefile.PL
@@ -3,6 +3,12 @@ name 'Array-Diff';
all_from 'lib/Array/Diff.pm';
test_requires 'Test::More';
+
+requires 'Algorithm::Diff';
+requires 'Class::Accessor::Fast';
+
+recommends 'Algorithm::Diff::XS';
+
use_test_base;
auto_include;
WriteAll;
View
17 lib/Array/Diff.pm
@@ -4,10 +4,11 @@ use warnings;
use base qw/Class::Accessor::Fast/;
use Algorithm::Diff;
+eval q{ use Algorithm::Diff::XS; };
our $VERSION = '0.04';
-__PACKAGE__->mk_accessors(qw/added deleted count/);
+__PACKAGE__->mk_accessors(qw/added deleted count diff_class/);
=head1 NAME
@@ -37,6 +38,18 @@ L<Algorithm::Diff>
=head1 METHODS
+=head2 new
+
+=cut
+
+sub new {
+ my $self = shift->SUPER::new(@_);
+
+ $self->{diff_class} ||= $INC{'Algorithm/Diff/XS.pm'} ? 'Algorithm::Diff::XS' : 'Algorithm::Diff';
+
+ $self;
+}
+
=head2 diff
=cut
@@ -49,7 +62,7 @@ sub diff {
$self->deleted( [] );
$self->count( 0 );
- my $diff = Algorithm::Diff->new( $old, $new );
+ my $diff = $self->diff_class->new( $old, $new );
while ( $diff->Next ) {
next if $diff->Same;
View
4 t/00_compile.t
@@ -1,4 +0,0 @@
-use strict;
-use Test::More tests => 1;
-
-BEGIN { use_ok 'Array::Diff' }
Please sign in to comment.
Something went wrong with that request. Please try again.