Commit 43dd2515 by Vincent Pelletier

ERP5Type.Core.Folder: Optimise _getFolderHandlerData.

Backward-compatibility path does not need to be fast. Optimise for sane
1 parent 735d4748
......@@ -671,10 +671,17 @@ class Folder(CopyContainer, OFSFolder2, CMFBTreeFolder, CMFHBTreeFolder, Base, F
def _getFolderHandlerData(self):
# Internal API working around bogus _folder_handler values.
folder_handler = self._folder_handler
if folder_handler == _BROKEN_BTREE_HANDLER:
folder_handler = BTREE_HANDLER
return _HANDLER_LIST[folder_handler]
# This method is a hot-spot for all Folder accesses. DO NOT SLOW IT DOWN.
# Fast path: folder is sane.
return _HANDLER_LIST[self._folder_handler]
# Note: TypeError and not IndexError, as bogus value is a string and
# _HANDLER_LIST only accepts integers indices.
except TypeError:
# Slow path: handle insane folders.
if self._folder_handler == _BROKEN_BTREE_HANDLER:
security.declareProtected(Permissions.AccessContentsInformation, 'isBTree')
def isBTree(self):
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!