Changeset 6233


Ignore:
Timestamp:
30 May 2011, 00:22:11 (13 years ago)
Author:
uli
Message:

Replace old clear() implementation with a call to internal function
implemented in C. This way we not only get tremendous speedup for the
clear-action but also kick a faulty implementation. The old one
removed only half of the items contained and the test didn't check
that properly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/university/certificatecontainer.py

    r6227 r6233  
    3939
    4040    def clear(self):
    41         keys = self.keys()
    42         for key in keys:
    43             del self[key]
     41        """Remove all contents from the certificate container.
     42        """
     43        # This internal function is implemented in C and thus much
     44        # faster as we could do it in pure Python.
     45        self._SampleContainer__data.clear()
     46        # The length attribute is 'lazy'. See `zope.container` for details.
     47        # This way we make sure, the next time len() is called, it returns
     48        # the real value and not a cached one.
     49        del self.__dict__['_BTreeContainer__len']
    4450
    4551class CertificateContainerFactory(grok.GlobalUtility):
Note: See TracChangeset for help on using the changeset viewer.