mirror of
https://github.com/python/cpython.git
synced 2025-12-11 11:31:05 +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:
|
if acquire and release and handlers:
|
||||||
acquire()
|
acquire()
|
||||||
try:
|
try:
|
||||||
if wr in handlers:
|
|
||||||
handlers.remove(wr)
|
handlers.remove(wr)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
finally:
|
finally:
|
||||||
release()
|
release()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue