Commit bd3b9cfd authored by Vincent Pelletier's avatar Vincent Pelletier

Micro optimisation: disable/enable function rather than testing upon call.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2460 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 8014adfe
...@@ -41,12 +41,23 @@ def OOBTree(): ...@@ -41,12 +41,23 @@ def OOBTree():
result = TREE_POOL.pop() result = TREE_POOL.pop()
except IndexError: except IndexError:
result = _OOBTree() result = _OOBTree()
# Next btree we prune will have room, restore prune method
global prune
prune = _prune
return result return result
def prune(tree): def _prune(tree):
if len(TREE_POOL) < MAX_TREE_POOL_SIZE: tree.clear()
tree.clear() TREE_POOL.append(tree)
TREE_POOL.append(tree) if len(TREE_POOL) >= MAX_TREE_POOL_SIZE:
# Already at/above max pool size, disable ourselve.
global prune
prune = _noPrune
def _noPrune(_):
pass
prune = _prune
class CreationUndone(Exception): class CreationUndone(Exception):
pass pass
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment