changeset 8384:483d9b2103da

inotify: dic.setdefault(k, d) ; v = dic[k] --> v = dic.setdefault(k, d) dict.setdefault sets a default value, but also returns the dict.get result. Getting the value on the next instruction was redundant.
author Nicolas Dumazet <nicdumz.commits@gmail.com>
date Fri, 08 May 2009 16:28:52 +0900
parents dcfdcb51ac5c
children 1536501ade62
files hgext/inotify/server.py
diffstat 1 files changed, 2 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/inotify/server.py	Fri May 08 16:40:39 2009 +0900
+++ b/hgext/inotify/server.py	Fri May 08 16:28:52 2009 +0900
@@ -214,8 +214,7 @@
     def dir(self, tree, path):
         if path:
             for name in path.split('/'):
-                tree.setdefault(name, {})
-                tree = tree[name]
+                tree = tree.setdefault(name, {})
         return tree
 
     def lookup(self, path, tree):
@@ -438,8 +437,7 @@
         self.updatestatus(wpath, None)
 
     def schedule_work(self, wpath, evt):
-        self.eventq.setdefault(wpath, [])
-        prev = self.eventq[wpath]
+        prev = self.eventq.setdefault(wpath, [])
         try:
             if prev and evt == 'm' and prev[-1] in 'cm':
                 return