Optimization to system.inventory()

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

 



Here's an optimization to func '*' call system inventory.  It moves an inner
loop so that we only process the data inside of it once.

-Toshio
From ac1831291e32f3e91ba62d7d549a6297778686e3 Mon Sep 17 00:00:00 2001
From: Toshio Kuratomi <toshio@xxxxxxxxxxxxxxxxx>
Date: Tue, 27 Apr 2010 19:06:22 -0400
Subject: [PATCH] Remove an inner loop in system.inventory()

---
 func/minion/server.py |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/func/minion/server.py b/func/minion/server.py
index 101868d..0ee516e 100644
--- a/func/minion/server.py
+++ b/func/minion/server.py
@@ -139,13 +139,13 @@ class XmlRpcInterface(object):
         # see which are where, but that seems lame -akl
         for module in self.modules.keys():
             inventory[module] = []
-            for method in self.handlers.keys():
-                # string match, ick. 
-                method_bits = method.split('.')
-                method_module = string.join(method_bits[:-1], '.')
-                method_name = method_bits[-1]
-                if method_module == module:
-                    inventory[module].append(method_name)
+        for method in self.handlers.keys():
+            # string match, ick. 
+            method_bits = method.split('.')
+            method_module = string.join(method_bits[:-1], '.')
+            method_name = method_bits[-1]
+            if method_module in inventory:
+                inventory[module_module].append(method_name)
 
         return inventory
 
-- 
1.6.6.1

Attachment: pgpAkJkPCsdEE.pgp
Description: PGP signature

_______________________________________________
Func-list mailing list
Func-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/func-list

[Index of Archives]     [Fedora Users]     [Linux Networking]     [Fedora Legacy List]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux