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.
--- 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