Use our $blah_q //= ... since these are used only here.  This is a
cheap kind of memoisation of a global constant.

Reported-by: George Dunlap <george.dun...@citrix.com>
Signed-off-by: Ian Jackson <ian.jack...@eu.citrix.com>
---
 mg-hosts | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/mg-hosts b/mg-hosts
index b62e430..2ed42fc 100755
--- a/mg-hosts
+++ b/mg-hosts
@@ -403,18 +403,19 @@ END
     print $o or die $!;
 }
 
-our $flag_clear_q = $dbh_tests->prepare(<<END);
+sub setflagval ($$$) {
+    my ($dst,$flag,$value) = @_;
+
+    our $flag_clear_q //= $dbh_tests->prepare(<<END);
                     DELETE FROM hostflags
                           WHERE hostname=? AND hostflag=?
 END
-our $flag_set_q = $dbh_tests->prepare(<<END);
+    our $flag_set_q //= $dbh_tests->prepare(<<END);
                     INSERT INTO hostflags
                                 (hostname, hostflag)
                          VALUES (?,        ?       )
 END
 
-sub setflagval ($$$) {
-    my ($dst,$flag,$value) = @_;
     $flag_clear_q->execute($dst,$flag);
     $flag_set_q->execute($dst,$flag) if $value;
 }
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

Reply via email to