changeset 8320:a1305c1c8d8e

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.
author Nicolas Dumazet <nicdumz.commits@gmail.com>
date Mon, 04 May 2009 16:57:52 +0900
parents 1c5d93b225f7
children ec985dcfd7da
files hgext/inotify/server.py
diffstat 1 files changed, 5 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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'