From 304676b6aafd9ec22d73db23633dc8f120c49967 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Wed, 24 Oct 2012 20:36:32 +0200 Subject: [PATCH] Use XML::SAX::ExpatXS if available --- Build.PL | 2 +- lib/Slic3r/Format/AMF.pm | 11 +++++++---- lib/Slic3r/Format/AMF/Parser.pm | 2 -- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Build.PL b/Build.PL index 4ad56e18e..e34a56d0f 100644 --- a/Build.PL +++ b/Build.PL @@ -26,7 +26,7 @@ my $build = Module::Build->new( recommends => { 'Growl::GNTP' => '0.15', 'Net::DBus' => '0', - 'XML::SAX' => '0', + 'XML::SAX::ExpatXS' => '0', 'Wx' => '0.9901', }, script_files => ['slic3r.pl'], diff --git a/lib/Slic3r/Format/AMF.pm b/lib/Slic3r/Format/AMF.pm index d654ca1a5..0e44353cf 100644 --- a/lib/Slic3r/Format/AMF.pm +++ b/lib/Slic3r/Format/AMF.pm @@ -7,14 +7,17 @@ sub read_file { my $self = shift; my ($file) = @_; - eval "require Slic3r::Format::AMF::Parser; 1" - or die "AMF parsing requires XML::SAX\n"; + eval qq{ + require Slic3r::Format::AMF::Parser; + use XML::SAX::ParserFactory; + 1; + } or die "AMF parsing requires XML::SAX\n"; open my $fh, '<', $file or die "Failed to open $file\n"; my $model = Slic3r::Model->new; - XML::SAX::PurePerl - ->new(Handler => Slic3r::Format::AMF::Parser->new(_model => $model)) + XML::SAX::ParserFactory + ->parser(Handler => Slic3r::Format::AMF::Parser->new(_model => $model)) ->parse_file($fh); close $fh; diff --git a/lib/Slic3r/Format/AMF/Parser.pm b/lib/Slic3r/Format/AMF/Parser.pm index 173dfc091..22e4204b3 100644 --- a/lib/Slic3r/Format/AMF/Parser.pm +++ b/lib/Slic3r/Format/AMF/Parser.pm @@ -2,8 +2,6 @@ package Slic3r::Format::AMF::Parser; use strict; use warnings; -use XML::SAX::PurePerl; - use base 'XML::SAX::Base'; my %xyz_index = (x => 0, y => 1, z => 2); #=