Optimised Placeholders handling of child loggers by using a dict rather than a list (much slower in the pathological case of hundreds of child Loggers to a Placeholder - problem reported by Ryan Blazecka).

This commit is contained in:
Vinay Sajip 2005-10-14 09:36:35 +00:00
parent 98fcaaf48e
commit 239322b97e

View File

@ -783,14 +783,17 @@ class PlaceHolder:
""" """
Initialize with the specified logger being a child of this placeholder. Initialize with the specified logger being a child of this placeholder.
""" """
self.loggers = [alogger] #self.loggers = [alogger]
self.loggerMap = { alogger : None }
def append(self, alogger): def append(self, alogger):
""" """
Add the specified logger as a child of this placeholder. Add the specified logger as a child of this placeholder.
""" """
if alogger not in self.loggers: #if alogger not in self.loggers:
self.loggers.append(alogger) if not self.loggerMap.has_key(alogger):
#self.loggers.append(alogger)
self.loggerMap[alogger] = None
# #
# Determine which class to use when instantiating loggers. # Determine which class to use when instantiating loggers.
@ -892,7 +895,8 @@ class Manager:
Ensure that children of the placeholder ph are connected to the Ensure that children of the placeholder ph are connected to the
specified logger. specified logger.
""" """
for c in ph.loggers: #for c in ph.loggers:
for c in ph.loggerMap.keys():
if string.find(c.parent.name, alogger.name) <> 0: if string.find(c.parent.name, alogger.name) <> 0:
alogger.parent = c.parent alogger.parent = c.parent
c.parent = alogger c.parent = alogger