mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-18 07:47:17 +00:00
Move more attribute lookups out of loops for speed
This commit is contained in:
parent
ff146e1cb1
commit
7fdbfa2cf4
2 changed files with 16 additions and 6 deletions
|
@ -204,8 +204,13 @@ class LineCache (Producer):
|
|||
"W" : debug_level_warning, " " : debug_level_none}
|
||||
rexp = re.compile (r"\d:\d\d:\d\d\.\d+\s+\d+\s+0x[0-9a-f]+\s+([DLIEW ])")
|
||||
|
||||
# Moving attribute lookups out of the loop:
|
||||
readline = self.__fileobj.readline
|
||||
tell = self.__fileobj.tell
|
||||
rexp_match = rexp.match
|
||||
levels_append = levels.append
|
||||
offsets_append = offsets.append
|
||||
dict_levels_get = dict_levels.get
|
||||
|
||||
self.__fileobj.seek (0)
|
||||
limit = self._lines_per_iteration
|
||||
|
@ -215,11 +220,11 @@ class LineCache (Producer):
|
|||
line = readline ()
|
||||
if not line:
|
||||
break
|
||||
match = rexp.match (line)
|
||||
match = rexp_match (line)
|
||||
if match is None:
|
||||
continue
|
||||
levels.append (dict_levels.get (match.group (1), debug_level_none))
|
||||
offsets.append (offset)
|
||||
levels_append (dict_levels_get (match.group (1), debug_level_none))
|
||||
offsets_append (offset)
|
||||
i += 1
|
||||
if i >= limit:
|
||||
i = 0
|
||||
|
|
|
@ -209,10 +209,15 @@ class LogModelBase (gtk.GenericTreeModel):
|
|||
|
||||
def iter_rows_offset (self):
|
||||
|
||||
ensure_cached = self.ensure_cached
|
||||
line_cache = self.line_cache
|
||||
line_levels = self.line_levels
|
||||
COL_LEVEL = self.COL_LEVEL
|
||||
|
||||
for i, offset in enumerate (self.line_offsets):
|
||||
self.ensure_cached (offset)
|
||||
row = self.line_cache[offset]
|
||||
row[self.COL_LEVEL] = self.line_levels[i] # FIXME
|
||||
ensure_cached (offset)
|
||||
row = line_cache[offset]
|
||||
row[COL_LEVEL] = line_levels[i] # FIXME
|
||||
yield (row, offset,)
|
||||
|
||||
def on_get_flags (self):
|
||||
|
|
Loading…
Reference in a new issue