[Neo-report] r2460 vincent - /trunk/neo/storage/database/btree.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Nov 17 14:05:14 CET 2010
Author: vincent
Date: Wed Nov 17 14:05:13 2010
New Revision: 2460
Log:
Micro optimisation: disable/enable function rather than testing upon call.
Modified:
trunk/neo/storage/database/btree.py
Modified: trunk/neo/storage/database/btree.py
==============================================================================
--- trunk/neo/storage/database/btree.py [iso-8859-1] (original)
+++ trunk/neo/storage/database/btree.py [iso-8859-1] Wed Nov 17 14:05:13 2010
@@ -41,12 +41,23 @@ def OOBTree():
result = TREE_POOL.pop()
except IndexError:
result = _OOBTree()
+ # Next btree we prune will have room, restore prune method
+ global prune
+ prune = _prune
return result
-def prune(tree):
- if len(TREE_POOL) < MAX_TREE_POOL_SIZE:
- tree.clear()
- TREE_POOL.append(tree)
+def _prune(tree):
+ tree.clear()
+ 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):
pass
More information about the Neo-report
mailing list