From a516e78bcf76f07545310332290b6c5443d437a7 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Wed, 9 Mar 2011 04:56:53 +0100 Subject: Some optimizations in build_new_message. Also cleaned up. Added an optimized way to do "wcswidth(string) > n": wcsislonger. And should use less memory because the dict replacing Message and Lines object stores ONLY the needed attributes. --- src/room.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/room.py') diff --git a/src/room.py b/src/room.py index df97c638..99674aa0 100644 --- a/src/room.py +++ b/src/room.py @@ -19,7 +19,6 @@ from datetime import datetime from random import randrange from config import config from logger import logger -from message import Message import common import theme @@ -114,7 +113,17 @@ class Room(TextBuffer): color = theme.COLOR_INFORMATION_TEXT time = time if time is not None else datetime.now() nick_color = nick_color or user.color if user else None - message = Message(txt, time, nickname, nick_color, color, colorized, user=user) + message = {'txt': txt, 'colorized':colorized, + 'time':time} + if nickname: + message['nickname'] = nickname + if nick_color: + message['nick_color'] = nick_color + if color: + message['color'] = color + if user: + message['user'] = user + # message = Message(txt, time, nickname, nick_color, color, colorized, user=user) while len(self.messages) > self.messages_nb_limit: self.messages.pop(0) self.messages.append(message) -- cgit v1.2.3