From b7fb78abed1ec35f0ad0ba2dfdf360bd88b95ebc Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Tue, 27 Apr 2004 11:06:26 +0000 Subject: [PATCH] Slight optimization, finally figured out how to automatically intern all IrcStrings. --- src/ircutils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ircutils.py b/src/ircutils.py index 1fc2ed41a..b19a5898b 100644 --- a/src/ircutils.py +++ b/src/ircutils.py @@ -389,10 +389,12 @@ def unDccIP(i): class IrcString(str): """This class does case-insensitive comparison and hashing of nicks.""" + def __new__(cls, s=''): + return str.__new__(cls, intern(s)) + def __init__(self, s): assert isinstance(s, basestring), \ 'Cannot make an IrcString from %s' % type(s) - str.__init__(self, intern(s)) # This does nothing, I fear. self.lowered = toLower(s) def __eq__(self, s):