From fb974d9c26db844c754b75506a28f3ca9f5522ca Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Wed, 15 Jul 2015 18:42:24 +0200 Subject: [PATCH] Menu: YAML::XS benutzen wenn vorhanden --- SL/Menu.pm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/SL/Menu.pm b/SL/Menu.pm index d72bb3619..1ecb52fab 100644 --- a/SL/Menu.pm +++ b/SL/Menu.pm @@ -3,10 +3,15 @@ package SL::Menu; use strict; use SL::Auth; -use YAML::XS (); +use YAML (); use File::Spec; use SL::MoreCommon qw(uri_encode); +our $yaml_xs; +BEGIN { + $yaml_xs = eval { require YAML::XS }; +} + sub new { my ($package, $domain) = @_; @@ -19,7 +24,12 @@ sub new { my $nodes = []; my $nodes_by_id = {}; for my $file (@files) { - my $data = YAML::XS::LoadFile(File::Spec->catfile($path, $file)); + my $data; + if ($yaml_xs) { + $data = YAML::XS::LoadFile(File::Spec->catfile($path, $file)); + } else { + $data = YAML::LoadFile(File::Spec->catfile($path, $file)); + } _merge($nodes, $nodes_by_id, $data); } -- 2.20.1