From a3c10d31c77aece45da31748badbf26516d09cca Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Wed, 14 Sep 2011 17:17:54 +0200 Subject: [PATCH] http.client: Reduce performance impact by assertion Call dict.values once instead of N times. Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- lib/http/client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/http/client.py b/lib/http/client.py index 84cd0b7fa..1e02e4c2a 100644 --- a/lib/http/client.py +++ b/lib/http/client.py @@ -352,10 +352,11 @@ class HttpClientPool: """Returns HTTP clients to the pool. """ + assert not frozenset(pclients) & frozenset(self._pool.values()) + for pc in pclients: self._logger.debug("Returning client %s to pool", pc) assert pc.identity not in self._pool - assert pc not in self._pool.values() self._pool[pc.identity] = pc # Check for unused clients -- GitLab