From da0749b5d925a7a9261b168972899faebe697669 Mon Sep 17 00:00:00 2001 From: Stephan Erb <steve-e@h3c.de> Date: Mon, 28 Dec 2009 20:58:34 +0100 Subject: [PATCH] Make NullClientCaps a singleto so that we don't create a new object for each contact. --- launch.sh | 2 +- src/common/caps_cache.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/launch.sh b/launch.sh index 0c73c667c6..be228d543f 100755 --- a/launch.sh +++ b/launch.sh @@ -1,3 +1,3 @@ #!/bin/sh cd "$(dirname $0)/src" -exec python -OOt gajim.py "$@" +exec python -m cProfile gajim.py "$@" diff --git a/src/common/caps_cache.py b/src/common/caps_cache.py index 6a3b3591a0..f4bc02fcd2 100644 --- a/src/common/caps_cache.py +++ b/src/common/caps_cache.py @@ -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) -- GitLab