[PATCH 4 of 8 V5] worker: change "pids" to a set
Jun Wu
quark at fb.com
Mon Nov 14 21:39:07 EST 2016
# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1479175840 0
# Tue Nov 15 02:10:40 2016 +0000
# Node ID 2ab9239f357f1739b2a230bee69ad5eaa81493a6
# Parent 0abdc39524ef9845a82082f53499d83468ce7761
# Available At https://bitbucket.org/quark-zju/hg-draft
# hg pull https://bitbucket.org/quark-zju/hg-draft -r 2ab9239f357f
worker: change "pids" to a set
There is no need to keep any order of the "pids" array. A set is more
efficient for the "remove" operation. And the following patch will use that.
diff --git a/mercurial/worker.py b/mercurial/worker.py
--- a/mercurial/worker.py
+++ b/mercurial/worker.py
@@ -89,5 +89,5 @@ def _posixworker(ui, func, staticargs, a
oldhandler = signal.getsignal(signal.SIGINT)
signal.signal(signal.SIGINT, signal.SIG_IGN)
- pids, problem = [], [0]
+ pids, problem = set(), [0]
def killworkers():
# if one worker bails, there's no good reason to wait for the rest
@@ -119,6 +119,5 @@ def _posixworker(ui, func, staticargs, a
# other exceptions are allowed to propagate, we rely
# on lock.py's pid checks to avoid release callbacks
- pids.append(pid)
- pids.reverse()
+ pids.add(pid)
os.close(wfd)
fp = os.fdopen(rfd, 'rb', 0)
More information about the Mercurial-devel
mailing list