mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-29 14:19:25 +01:00
ircmsgs: Internalize prefix, server_tags keys, and command.
prefixes can be rather long, they have rather small cardinality, and they are repeated a lot in the history; so they take up a sizeable portion of memory. And let's also internalize commands and server_tags keys while I'm at it.
This commit is contained in:
parent
2682e4cb48
commit
c9c05cf8e1
@ -36,6 +36,7 @@ object (which, as you'll read later, is quite...full-featured :))
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
import time
|
import time
|
||||||
import base64
|
import base64
|
||||||
import datetime
|
import datetime
|
||||||
@ -81,7 +82,7 @@ def parse_server_tags(s):
|
|||||||
server_tags = {}
|
server_tags = {}
|
||||||
for tag in s.split(';'):
|
for tag in s.split(';'):
|
||||||
if '=' not in tag:
|
if '=' not in tag:
|
||||||
server_tags[tag] = None
|
server_tags[sys.intern(tag)] = None
|
||||||
else:
|
else:
|
||||||
(key, value) = tag.split('=', 1)
|
(key, value) = tag.split('=', 1)
|
||||||
value = unescape_server_tag_value(value)
|
value = unescape_server_tag_value(value)
|
||||||
@ -89,7 +90,7 @@ def parse_server_tags(s):
|
|||||||
# "Implementations MUST interpret empty tag values (e.g. foo=)
|
# "Implementations MUST interpret empty tag values (e.g. foo=)
|
||||||
# as equivalent to missing tag values (e.g. foo)."
|
# as equivalent to missing tag values (e.g. foo)."
|
||||||
value = None
|
value = None
|
||||||
server_tags[key] = value
|
server_tags[sys.intern(key)] = value
|
||||||
return server_tags
|
return server_tags
|
||||||
def format_server_tags(server_tags):
|
def format_server_tags(server_tags):
|
||||||
parts = []
|
parts = []
|
||||||
@ -212,6 +213,8 @@ class IrcMsg(object):
|
|||||||
self.server_tags = {}
|
self.server_tags = {}
|
||||||
else:
|
else:
|
||||||
self.server_tags = server_tags
|
self.server_tags = server_tags
|
||||||
|
self.prefix = sys.intern(self.prefix)
|
||||||
|
self.command = sys.intern(self.command)
|
||||||
self.args = tuple(self.args)
|
self.args = tuple(self.args)
|
||||||
if isUserHostmask(self.prefix):
|
if isUserHostmask(self.prefix):
|
||||||
(self.nick,self.user,self.host)=ircutils.splitHostmask(self.prefix)
|
(self.nick,self.user,self.host)=ircutils.splitHostmask(self.prefix)
|
||||||
|
Loading…
Reference in New Issue
Block a user