datetime.strftime seems (according to cProfile) to be VERY slow. Improve the...

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
parent 1c923fcd
......@@ -980,7 +980,7 @@ class MucListTab(Tab):
self.list_header = windows.ColumnHeaderWin(columns)
self.listview = windows.ListWin(columns)
self.tab_win = windows.GlobalInfoBar()
self.default_help_message = windows.HelpText("“j”: join room. “i”: information")
self.default_help_message = windows.HelpText("“j”: join room.")
self.input = self.default_help_message
self.key_func["KEY_DOWN"] = self.listview.move_cursor_down
self.key_func["KEY_UP"] = self.listview.move_cursor_up
......@@ -1065,6 +1065,18 @@ class MucListTab(Tab):
def get_color_state(self):
return self._color_state
# class SimpleTextTab(Tab):
# """
# A very simple tab, with just a text displaying some
# information or whatever
# """
# def __init__(self, core, text):
# Tab.__init__(self, core)
# self.text = text
# self.text_win =
# def resize(self):
# pass
def diffmatch(search, string):
"""
Use difflib and a loop to check if search_pattern can
......
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment