Make NullClientCaps a singleto so that we don't create a new object for each contact.

This commit is contained in:
Stephan Erb 2009-12-28 20:58:34 +01:00
parent 65ba840cbd
commit da0749b5d9
2 changed files with 11 additions and 1 deletions

View File

@ -1,3 +1,3 @@
#!/bin/sh
cd "$(dirname $0)/src"
exec python -OOt gajim.py "$@"
exec python -m cProfile gajim.py "$@"

View File

@ -245,6 +245,16 @@ class NullClientCaps(AbstractClientCaps):
Assumes (almost) everything is supported.
"""
_instance = None
def __new__(cls, *args, **kwargs):
"""
Make it a singleton.
"""
if not cls._instance:
cls._instance = super(NullClientCaps, cls).__new__(
cls, *args, **kwargs)
return cls._instance
def __init__(self):
AbstractClientCaps.__init__(self, None, None)