]> git.donarmstrong.com Git - debbugs.git/commitdiff
use feature state in Debbugs::Log for some small speed gain
authorDon Armstrong <don@donarmstrong.com>
Sat, 1 Jul 2017 17:43:23 +0000 (10:43 -0700)
committerDon Armstrong <don@donarmstrong.com>
Sat, 1 Jul 2017 17:43:23 +0000 (10:43 -0700)
Debbugs/Log.pm

index 5a7306de38ecfd5ecee354e06961aad60610badd..29559dd05f8bc378961f7516b500423c86f0527d 100644 (file)
@@ -41,6 +41,7 @@ use Debbugs::Common qw(getbuglocation getbugcomponent make_list);
 use Params::Validate qw(:types validate_with);
 use Encode qw(encode encode_utf8 is_utf8);
 use IO::InnerFile;
+use feature 'state';
 
 =head1 NAME
 
@@ -173,24 +174,28 @@ sub new
         $param{inner_file} = 0;
     }
     else {
-        %param = validate_with(params => \@_,
-                               spec   => {bug_num => {type => SCALAR,
-                                                      optional => 1,
-                                                     },
-                                          logfh   => {type => HANDLE,
-                                                      optional => 1,
-                                                     },
-                                          log_name => {type => SCALAR,
-                                                       optional => 1,
-                                   },
-                           inner_file => {type => BOOLEAN,
-                                          default => 0,
-                                         },
-                                         }
-                              );
+        state $spec =
+            {bug_num => {type => SCALAR,
+                         optional => 1,
+                        },
+             logfh   => {type => HANDLE,
+                         optional => 1,
+                        },
+             log_name => {type => SCALAR,
+                          optional => 1,
+                         },
+             inner_file => {type => BOOLEAN,
+                            default => 0,
+                           },
+            };
+        %param = validate_with(params => \@_,
+                               spec   => $spec,
+                              );
     }
-    if (grep({exists $param{$_} and defined $param{$_}} qw(bug_num logfh log_name)) ne 1) {
-        croak "Exactly one of bug_num, logfh, or log_name must be passed and must be defined";
+    if (grep({exists $param{$_} and defined $param{$_}}
+             qw(bug_num logfh log_name)) ne 1) {
+        croak "Exactly one of bug_num, logfh, or log_name ".
+            "must be passed and must be defined";
     }
 
     my $class = ref($this) || $this;