diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-02-04 10:55:45 -0800 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-02-04 10:55:45 -0800 |
commit | d8922b367e5d45dc8bb2b5dfba59d9473c3403e8 (patch) | |
tree | bfc40e70d24d8f4c6694c784e7d3c08ceb6d0f2a /lib/Vyatta | |
parent | eb17b185a339fb73059899f5a0bcbac987745002 (diff) | |
download | vyatta-cfg-d8922b367e5d45dc8bb2b5dfba59d9473c3403e8.tar.gz vyatta-cfg-d8922b367e5d45dc8bb2b5dfba59d9473c3403e8.zip |
Vyatta::Config - simplify boolean
When returning boolean no need to have
if (expr) return 1; else return 0
Also the proper boolean for false is undef not 0.
Diffstat (limited to 'lib/Vyatta')
-rwxr-xr-x | lib/Vyatta/Config.pm | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/lib/Vyatta/Config.pm b/lib/Vyatta/Config.pm index d253236..86c8455 100755 --- a/lib/Vyatta/Config.pm +++ b/lib/Vyatta/Config.pm @@ -305,10 +305,7 @@ sub isDeleted { my $filepathNew = "$self->{_new_config_dir_base}$self->{_current_dir_level}/$node"; - if ((-e $filepathAct) && !(-e $filepathNew)) { - return 1; - } - return 0; + return ((-e $filepathAct) && !(-e $filepathNew)); } ## listDeleted("level") @@ -335,8 +332,7 @@ sub isChanged { my $filepath = "$self->{_changes_only_dir_base}$self->{_current_dir_level}/$node"; # if the node exists in the change dir, it's modified. - if (-e "$filepath") { return 1; } - else { return 0; } + return ( ! -e $filepath); } ## isChangedOrDeleted("node") @@ -358,11 +354,7 @@ sub isChangedOrDeleted { my $filepathNew = "$self->{_new_config_dir_base}$self->{_current_dir_level}/$node"; - if ((-e $filepathAct) && !(-e $filepathNew)) { - return 1; - } - - return 0; + return ((-e $filepathAct) && !(-e $filepathNew)); } ## isAdded("node") @@ -381,14 +373,13 @@ sub isAdded { # if the node doesn't exist in the modify dir, it's not # been added. so short circuit and return false. - if (! -e $filepathNewConfig) { return 0; } + return unless (-e $filepathNewConfig); # now let's setup the path for the working dir my $filepathActive = "$self->{_active_dir_base}$self->{_current_dir_level}/$node"; # if the node is in the active_dir it's not new - if (-e $filepathActive) { return 0; } - else { return 1; } + return (! -e $filepathActive); } ## listNodeStatus("level") @@ -484,10 +475,7 @@ sub isTagNode { my $tpath = $self->getTmplPath($cfg_path_ref); return unless $tpath; - if (-d "$tpath/node.tag") { - return 1; - } - return 0; + return (-d "$tpath/node.tag"); } sub hasTmplChildren { @@ -496,13 +484,11 @@ sub hasTmplChildren { my $tpath = $self->getTmplPath($cfg_path_ref); return unless $tpath; - opendir(TDIR, $tpath) or return 0; + opendir(TDIR, $tpath) or return; my @tchildren = grep !/^node\.def$/, (grep !/^\./, (readdir TDIR)); closedir TDIR; - if (scalar(@tchildren) > 0) { - return 1; - } - return 0; + + return (scalar(@tchildren) > 0); } # $cfg_path_ref: ref to array containing the node path. |