[PATCH 3/5] Get new devices only once in the _do_refresh method

Vratislav Podzimek vpodzime at redhat.com
Fri Mar 14 11:34:22 UTC 2014


Getting new devices is not a super-cheap operation and there's no need to run it
multiple times in this case. Especially if we are only interested in if it is
empty or not in some cases.

Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
 pyanaconda/ui/gui/spokes/custom.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index c8db0ec..db6fc21 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -443,16 +443,18 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
         self._removeButton.set_sensitive(False)
         self._configButton.set_sensitive(False)
 
+        new_devices = self.new_devices
+
         # Now it's time to populate the accordion.
         log.debug("ui: devices=%s", [d.name for d in self._devices])
         log.debug("ui: unused=%s", [d.name for d in self.unusedDevices])
-        log.debug("ui: new_devices=%s", [d.name for d in self.new_devices])
+        log.debug("ui: new_devices=%s", [d.name for d in new_devices])
 
         ui_roots = self._storage_playground.roots[:]
 
         # If we've not yet run autopart, add an instance of CreateNewPage.  This
         # ensures it's only added once.
-        if not self.new_devices:
+        if not new_devices:
             page = CreateNewPage(translated_new_install_name(),
                                  self.on_create_clicked,
                                  self._change_autopart_type,
@@ -465,10 +467,10 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
                             {"name" : productName, "version" : productVersion})
         else:
             swaps = [d for d in self.new_devices if d.format.type == "swap"]
-            mounts = dict((d.format.mountpoint, d) for d in self.new_devices
+            mounts = dict((d.format.mountpoint, d) for d in new_devices
                                 if getattr(d.format, "mountpoint", None))
 
-            for device in self.new_devices:
+            for device in new_devices:
                 if device in self.bootLoaderDevices:
                     mounts[device.format.type] = device
 
-- 
1.8.5.3



More information about the anaconda-patches mailing list