mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-44222: Improve _removeHandlerRef() for a very long _handlerList (GH-26325)
The list lookups become a big burden for very long lists. This patch changes the "happy flow" path of 2 lookups into 1 lookup. Automerge-Triggered-By: GH:vsajip
This commit is contained in:
parent
add805f921
commit
156699bca0
1 changed files with 3 additions and 2 deletions
|
@ -845,8 +845,9 @@ def _removeHandlerRef(wr):
|
|||
if acquire and release and handlers:
|
||||
acquire()
|
||||
try:
|
||||
if wr in handlers:
|
||||
handlers.remove(wr)
|
||||
handlers.remove(wr)
|
||||
except ValueError:
|
||||
pass
|
||||
finally:
|
||||
release()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue