Change in vdsm[master]: net: getLinks: avoid redundant list creation

danken at redhat.com danken at redhat.com
Fri Sep 12 08:57:54 UTC 2014


Dan Kenigsberg has uploaded a new change for review.

Change subject: net: getLinks: avoid redundant list creation
......................................................................

net: getLinks: avoid redundant list creation

Returning an iterator is cheaper than creating a possibly-long
throwaway list.

Change-Id: I566b145d76dee6724a4d84c45d9cb2098fae9df7
Signed-off-by: Dan Kenigsberg <danken at redhat.com>
---
M lib/vdsm/ipwrapper.py
1 file changed, 2 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/44/32844/1

diff --git a/lib/vdsm/ipwrapper.py b/lib/vdsm/ipwrapper.py
index 9e38bf6..c2bbdd8 100644
--- a/lib/vdsm/ipwrapper.py
+++ b/lib/vdsm/ipwrapper.py
@@ -305,14 +305,12 @@
 
 
 def getLinks():
-    """Returns a list of Link objects for each link in the system."""
-    links = []
+    """Return an iterator of Link objects, each per a link in the system."""
     for data in link.iter_links():
         try:
-            links.append(Link.fromDict(data))
+            yield Link.fromDict(data)
         except IOError:  # If a link goes missing we just don't report it
             continue
-    return links
 
 
 def getLink(dev):


-- 
To view, visit http://gerrit.ovirt.org/32844
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I566b145d76dee6724a4d84c45d9cb2098fae9df7
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken at redhat.com>


More information about the vdsm-patches mailing list