further tweaks on ltt_trace_facility_by_id
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Mon, 16 Aug 2004 04:02:44 +0000 (04:02 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Mon, 16 Aug 2004 04:02:44 +0000 (04:02 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@788 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/ltt/tracefile.c

index 292c207920ba43773c70f41bb7e7aab91f8178e4..061cb74356357ac0ac99f23fcd5d29d1ea61d8e8 100644 (file)
@@ -681,8 +681,10 @@ unsigned ltt_trace_eventtype_number(LttTrace *t)
 {
   unsigned int i;
   unsigned count = 0;
+  unsigned int num = t->facility_number;
   LttFacility * f;
-  for(i=0;i<t->facility_number;i++){
+  
+  for(i=0;i<num;i++){
     f = (LttFacility*)g_ptr_array_index(t->facilities, i);
     count += f->event_number;
   }
@@ -696,17 +698,23 @@ LttFacility * ltt_trace_facility_by_id(LttTrace * trace, unsigned id)
 {
   LttFacility * facility = NULL;
   unsigned int i;
+  unsigned int num = trace->facility_number;
+  GPtrArray *facilities = trace->facilities;
 
-  for(i=0;i<trace->facility_number;i++){
+  for(i=0;unlikely(i<num);){
     LttFacility *iter_facility =
-                      (LttFacility*) g_ptr_array_index(trace->facilities,i);
-    if(likely(id >= iter_facility->base_id && 
-       id < iter_facility->base_id + iter_facility->event_number)) {
+                      (LttFacility*) g_ptr_array_index(facilities,i);
+    unsigned base_id = iter_facility->base_id;
+
+    if(likely(id >= base_id && 
+       id < base_id + iter_facility->event_number)) {
       facility = iter_facility;
       break;
+    } else {
+      i++;
     }
   }
-
+  
   return facility;
 }
 
@@ -1767,7 +1775,7 @@ static inline gint getFieldtypeSize(LttTracefile * t,
       }else if(likely(fld->field_fixed == 0)){
         offset1 = offsetRoot;
         offset2 = 0;
-        for(i=0;i<element_number;i++){
+        for(i=0;unlikely(i<element_number);i++){
           size=getFieldtypeSize(t,evT,offset1,offset2,
                                 fld->child[i],evD+offset2, trace);
           offset1 += size;
This page took 0.026921 seconds and 4 git commands to generate.