Slight optimization, finally figured out how to automatically intern all IrcStrings.

This commit is contained in:
Jeremy Fincher 2004-04-27 11:06:26 +00:00
parent 41a1c9f4d1
commit b7fb78abed
1 changed files with 3 additions and 1 deletions

View File

@ -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):