[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH 1/2] mg-hosts: Fix another couple of prepared statements



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.Dunlap@xxxxxxxxxx>
Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
 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@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.