summaryrefslogtreecommitdiff
path: root/src/windows.py
diff options
context:
space:
mode:
authorlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-12-21 05:43:57 +0000
committerlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-12-21 05:43:57 +0000
commitac3e0f7099352254cba53d14d896dc05c9c55e6f (patch)
treea61ff207aa07a2a39e1068111bb00904eef503f1 /src/windows.py
parent1c923fcdcc60a90fd6e2ebf09c5d4464f16995fd (diff)
downloadpoezio-ac3e0f7099352254cba53d14d896dc05c9c55e6f.tar.gz
poezio-ac3e0f7099352254cba53d14d896dc05c9c55e6f.tar.bz2
poezio-ac3e0f7099352254cba53d14d896dc05c9c55e6f.tar.xz
poezio-ac3e0f7099352254cba53d14d896dc05c9c55e6f.zip
datetime.strftime seems (according to cProfile) to be VERY slow. Improve the refresh performances by reducing A LOT the number of call of this method
Diffstat (limited to 'src/windows.py')
-rw-r--r--src/windows.py31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/windows.py b/src/windows.py
index f4524ff1..9d38cd84 100644
--- a/src/windows.py
+++ b/src/windows.py
@@ -470,8 +470,13 @@ class TextWin(Win):
if not first:
nick = None
time = None
- else:
- time = message.time
+ else: # strftime is VERY slow, improve performance
+ # by calling it only one time here, and
+ # not at each refresh
+ time = {'hour': '%s'%(message.time.strftime("%H"),),
+ 'minute': '%s'%(message.time.strftime("%M"),),
+ 'second': '%s'%(message.time.strftime("%S"),),
+ }
l = Line(nick, color,
time,
txt[:limit], message.color,
@@ -589,12 +594,12 @@ class TextWin(Win):
Write the date on the yth line of the window
"""
self.addstr(theme.CHAR_TIME_LEFT, curses.color_pair(theme.COLOR_TIME_LIMITER))
- self.addstr(time.strftime("%H"), curses.color_pair(theme.COLOR_TIME_NUMBERS))
+ self.addstr(time['hour'], curses.color_pair(theme.COLOR_TIME_NUMBERS))
self.addstr(':', curses.color_pair(theme.COLOR_TIME_SEPARATOR))
- self.addstr(time.strftime("%M"), curses.color_pair(theme.COLOR_TIME_NUMBERS))
+ self.addstr(time['minute'], curses.color_pair(theme.COLOR_TIME_NUMBERS))
self.addstr(':', curses.color_pair(theme.COLOR_TIME_SEPARATOR))
- self.addstr(time.strftime('%S'), curses.color_pair(theme.COLOR_TIME_NUMBERS))
- self.addnstr(theme.CHAR_TIME_RIGHT, curses.color_pair(theme.COLOR_TIME_LIMITER))
+ self.addstr(time['second'], curses.color_pair(theme.COLOR_TIME_NUMBERS))
+ self.addstr(theme.CHAR_TIME_RIGHT, curses.color_pair(theme.COLOR_TIME_LIMITER))
self.addstr(' ')
def resize(self, height, width, y, x, stdscr, room=None):
@@ -1425,3 +1430,17 @@ class ColumnHeaderWin(Win):
self.addstr(0, x, txt, curses.color_pair(theme.COLOR_STATUS_UNAVAILABLE))
x += size
self._refresh()
+
+# class SimpleTextWin(Win):
+# def __init__(self, text):
+# self._text = text
+# self.built_lines = []
+
+# def resize(self, height, width, y, x, stdscr):
+# self._resize(height, width, y, x, stdscr)
+# self.rebuild_text()
+
+# def rebuild_text(self):
+
+# def refresh(self):
+# pass