kconfig lib: make tree walking a generator
authorJohannes Berg <johannes.berg@intel.com>
Fri, 5 Apr 2013 18:02:55 +0000 (20:02 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 5 Apr 2013 18:03:08 +0000 (20:03 +0200)
Instead of building the list in memory first, just
use a generator.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
lib/kconfig.py

index 48226361932b817720a152ff7f47fcb8aebfbee4..2369f746fa8a2aed07b44a22c4098e71b08eac22 100644 (file)
@@ -15,12 +15,12 @@ class ConfigTree(object):
         self.rootfile = os.path.basename(rootfile)
 
     def _walk(self, f):
-        list = [f]
+        yield f
         for l in open(os.path.join(self.basedir, f), 'r'):
             m = src_line.match(l)
             if m and os.path.exists(os.path.join(self.basedir, m.group('src'))):
-                list.extend(self._walk(m.group('src')))
-        return list
+                for i in self._walk(m.group('src')):
+                    yield i
 
     def _prune_sources(self, f, ignore):
         for nf in self._walk(f):