trappy: remove double check for unique word
Its not necessary to check for unique word twice. Reusing the 'class detection'
path for this purpose is sufficient. This improve performance by 3-6% of the
parsing stage.
@@ -252,20 +252,12 @@ subclassed by FTrace (for parsing FTrace coming from trace-cmd) and SysTrace."""
def __populate_data(self, fin, cls_for_unique_word):
"""Append to trace data from a txt trace"""
- def contains_unique_word(line, unique_words=cls_for_unique_word.keys()):
- for unique_word in unique_words:
- if unique_word in line:
- return True
- return False
-
actual_trace = itertools.dropwhile(self.trace_hasnt_started(), fin)
actual_trace = itertools.takewhile(self.trace_hasnt_finished(),
actual_trace)
for line in actual_trace:
- if not contains_unique_word(line):
- self.lines += 1
- continue
+ trace_class = None
for unique_word, cls in cls_for_unique_word.iteritems():
if unique_word in line:
trace_class = cls
@@ -273,7 +265,8 @@ subclassed by FTrace (for parsing FTrace coming from trace-cmd) and SysTrace."""
break
else:
if not trace_class:
- raise FTraceParseError("No unique word in '{}'".format(line))
+ self.lines += 1
+ continue
line = line[:-1]
