tracer/parser: use local vars in the iterator function
authorStefan Sauer <ensonic@users.sf.net>
Tue, 20 Dec 2016 08:25:30 +0000 (09:25 +0100)
committerStefan Sauer <ensonic@users.sf.net>
Tue, 20 Dec 2016 08:25:30 +0000 (09:25 +0100)
This saves variable lookups in this thight loop.

tracer/tracer/parser.py

index ff05117..7c5c4eb 100644 (file)
@@ -73,9 +73,11 @@ class Parser(object):
         return self
 
     def __next__(self):
+        log_regex = self.log_regex
+        data = self.data
         while True:
-            line = next(self.data)
-            match = self.log_regex.match(line)
+            line = next(data)
+            match = log_regex.match(line)
             if match:
                 g = list(match.groups())
                 g[Parser.F_PID] = int(g[Parser.F_PID])