Mercurial > hg
comparison hgext/inotify/server.py @ 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 |
comparison
equal
deleted
inserted
replaced
8383:dcfdcb51ac5c | 8384:483d9b2103da |
---|---|
212 raise 'wtf? ' + path | 212 raise 'wtf? ' + path |
213 | 213 |
214 def dir(self, tree, path): | 214 def dir(self, tree, path): |
215 if path: | 215 if path: |
216 for name in path.split('/'): | 216 for name in path.split('/'): |
217 tree.setdefault(name, {}) | 217 tree = tree.setdefault(name, {}) |
218 tree = tree[name] | |
219 return tree | 218 return tree |
220 | 219 |
221 def lookup(self, path, tree): | 220 def lookup(self, path, tree): |
222 if path: | 221 if path: |
223 try: | 222 try: |
436 return | 435 return |
437 | 436 |
438 self.updatestatus(wpath, None) | 437 self.updatestatus(wpath, None) |
439 | 438 |
440 def schedule_work(self, wpath, evt): | 439 def schedule_work(self, wpath, evt): |
441 self.eventq.setdefault(wpath, []) | 440 prev = self.eventq.setdefault(wpath, []) |
442 prev = self.eventq[wpath] | |
443 try: | 441 try: |
444 if prev and evt == 'm' and prev[-1] in 'cm': | 442 if prev and evt == 'm' and prev[-1] in 'cm': |
445 return | 443 return |
446 self.eventq[wpath].append(evt) | 444 self.eventq[wpath].append(evt) |
447 finally: | 445 finally: |