inotify: inotify.server.walk() simplify algorithm
authorNicolas Dumazet <nicdumz.commits@gmail.com>
Mon, 04 May 2009 16:57:52 +0900
changeset 8320 a1305c1c8d8e
parent 8319 1c5d93b225f7
child 8321 ec985dcfd7da
inotify: inotify.server.walk() simplify algorithm Do not yield (bool, tuple) in a subfunction and check later: 'if not bool: yield tuple'. Instead simplify so the tuple doesnt get yielded on the first time, to avoid systematic checks.
hgext/inotify/server.py
--- a/hgext/inotify/server.py	Mon May 04 16:43:28 2009 +0900
+++ b/hgext/inotify/server.py	Mon May 04 16:57:52 2009 +0900
@@ -78,21 +78,20 @@
                     dirs.append(name)
                 elif kind in (stat.S_IFREG, stat.S_IFLNK):
                     files.append((name, kind))
-
-            yield hginside, fullpath, dirs, files
+            if reporoot or not hginside:
+                yield fullpath, dirs, files
 
             for subdir in dirs:
                 path = join(root, subdir)
                 if repo.dirstate._ignore(path):
                     continue
                 for result in walkit(path, False):
-                    if not result[0]:
-                        yield result
+                    yield result
         except OSError, err:
             if err.errno not in walk_ignored_errors:
                 raise
-    for result in walkit(root, root == ''):
-        yield result[1:]
+
+    return walkit(root, root == '')
 
 def _explain_watch_limit(ui, repo, count):
     path = '/proc/sys/fs/inotify/max_user_watches'