From a13d34a6acf9691b387c64a70da999ce84b32649 Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Mon, 19 Nov 2012 22:09:47 +0100
Subject: [PATCH] locking: Use frozenset instead of utils.UniqueSequence
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

In this case β€œfrozenset” is good enough as the result's order doesn't
matter--it is the input to β€œsorted” (β€œutils.UniqueSequence” preserves
the order). β€œfrozenset” is ca. 25% faster for this use-case.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 lib/locking.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/locking.py b/lib/locking.py
index e49478534..7d65d3395 100644
--- a/lib/locking.py
+++ b/lib/locking.py
@@ -1191,7 +1191,7 @@ class LockSet:
     # they will still be there after, but this makes it a lot faster should
     # just one of them be the already wrong. Using a sorted sequence to prevent
     # deadlocks.
-    for lname in sorted(utils.UniqueSequence(names)):
+    for lname in sorted(frozenset(names)):
       try:
         lock = self.__lockdict[lname] # raises KeyError if lock is not there
       except KeyError:
-- 
GitLab