Patchwork [v2,02/11] trace: [tracetool] Do not rebuild event list in backend code

login
register
mail settings
Submitter Lluís Vilanova
Date Feb. 3, 2012, 9:11 p.m.
Message ID <20120203211103.30134.84743.stgit@ginnungagap.bsc.es>
Download mbox | patch
Permalink /patch/139456/
State New
Headers show

Comments

Lluís Vilanova - Feb. 3, 2012, 9:11 p.m.
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
---
 scripts/tracetool.py |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

Patch

diff --git a/scripts/tracetool.py b/scripts/tracetool.py
index f0d7e1e..7042728 100755
--- a/scripts/tracetool.py
+++ b/scripts/tracetool.py
@@ -171,15 +171,14 @@  def simple_c(events):
     print
     print 'TraceEvent trace_list[] = {'
     print
-    eventlist = list(events)
-    for event in eventlist:
+    for event in events:
         print '{.tp_name = "%(name)s", .state=0},' % {
     'name': event.name
 }
         print
     print '};'
     print
-    for event in eventlist:
+    for event in events:
         argc = event.argc
         print '''void trace_%(name)s(%(args)s)
 {
@@ -311,8 +310,7 @@  def ust_c(events):
 #undef inline
 #undef wmb
 #include "trace.h"'''
-    eventlist = list(events)
-    for event in eventlist:
+    for event in events:
         argnames = event.argnames
         if event.argc > 0:
             argnames = ', ' + event.argnames
@@ -344,7 +342,7 @@  static void ust_%(name)s_probe(%(args)s)
     print '''
 static void __attribute__((constructor)) trace_init(void)
 {'''
-    for event in eventlist:
+    for event in events:
         print '    register_trace_ust_%(name)s(ust_%(name)s_probe);' % {
     'name': event.name
 }
@@ -510,14 +508,16 @@  class Event(object):
 
 # Generator that yields Event objects given a trace-events file object
 def read_events(fobj):
+    res = []
     event_num = 0
     for line in fobj:
         if not line.strip():
             continue
         if line.lstrip().startswith('#'):
 	    continue
-	yield Event(event_num, line)
+	res.append(Event(event_num, line))
 	event_num += 1
+    return res
 
 backend = ""
 output = ""