mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-26 04:32:51 +01:00
Seen, ChannelUserDictionary: Internalize channel names.
They are not many of them, but they are used a lot so they take up a surprising amount of memory.
This commit is contained in:
parent
08f4c781cb
commit
2682e4cb48
@ -65,6 +65,7 @@ class SeenDB(plugins.ChannelUserDB):
|
|||||||
|
|
||||||
def update(self, channel, nickOrId, saying):
|
def update(self, channel, nickOrId, saying):
|
||||||
seen = time.time()
|
seen = time.time()
|
||||||
|
channel = sys.intern(channel)
|
||||||
self[channel, nickOrId] = (seen, saying)
|
self[channel, nickOrId] = (seen, saying)
|
||||||
self[channel, '<last>'] = (seen, saying)
|
self[channel, '<last>'] = (seen, saying)
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
import gc
|
import gc
|
||||||
import os
|
import os
|
||||||
import csv
|
import csv
|
||||||
|
import sys
|
||||||
import time
|
import time
|
||||||
import codecs
|
import codecs
|
||||||
import string
|
import string
|
||||||
@ -188,6 +189,7 @@ class ChannelUserDictionary(collections.abc.MutableMapping):
|
|||||||
|
|
||||||
def __setitem__(self, key, v):
|
def __setitem__(self, key, v):
|
||||||
(channel, id) = key
|
(channel, id) = key
|
||||||
|
channel = sys.intern(channel)
|
||||||
if channel not in self.channels:
|
if channel not in self.channels:
|
||||||
self.channels[channel] = self.IdDict()
|
self.channels[channel] = self.IdDict()
|
||||||
self.channels[channel][id] = v
|
self.channels[channel][id] = v
|
||||||
@ -242,6 +244,7 @@ class ChannelUserDB(ChannelUserDictionary):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
# We'll skip over this so, say, nicks can be kept here.
|
# We'll skip over this so, say, nicks can be kept here.
|
||||||
pass
|
pass
|
||||||
|
channel = sys.intern(channel)
|
||||||
v = self.deserialize(channel, id, t)
|
v = self.deserialize(channel, id, t)
|
||||||
self[channel, id] = v
|
self[channel, id] = v
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
Loading…
Reference in New Issue
Block a user