home made strlen in critical path, tweak
[lttv.git] / ltt / branches / poly / ltt / tracefile.c
index 45ee588e6f69aafc86f9bb749efec85fbb41c1f7..d490dd9f0c8a13c3ed4389aa86b9bbee847a4619 100644 (file)
@@ -689,7 +689,8 @@ unsigned ltt_trace_eventtype_number(LttTrace *t)
 }
 
 /* FIXME : performances could be improved with a better design for this
- * function */
+ * function : sequential search through a container has never been the
+ * best on the critical path. */
 LttFacility * ltt_trace_facility_by_id(LttTrace * trace, unsigned id)
 {
   LttFacility * facility = NULL;
@@ -710,10 +711,15 @@ LttFacility * ltt_trace_facility_by_id(LttTrace * trace, unsigned id)
 
 LttEventType *ltt_trace_eventtype_get(LttTrace *t, unsigned evId)
 {
+  LttEventType *event_type;
+  
   LttFacility * f;
   f = ltt_trace_facility_by_id(t,evId);
-  if(!f) return NULL;
-  return f->events[evId - f->base_id];
+
+  if(unlikely(!f)) event_type = NULL;
+  else event_type = f->events[evId - f->base_id];
+
+  return event_type;
 }
 
 /*****************************************************************************
@@ -1657,7 +1663,8 @@ int getFieldtypeSize(LttTracefile * t, LttEventType * evT, int offsetRoot,
   LttType * type = fld->field_type;
 
   if(likely(t)){
-    if(unlikely(evT->latest_block==t->which_block && evT->latest_event==t->which_event)){
+    if(unlikely(evT->latest_block==t->which_block &&
+                evT->latest_event==t->which_event)){
       return fld->field_size;
     } 
   }
@@ -1716,7 +1723,11 @@ int getFieldtypeSize(LttTracefile * t, LttEventType * evT, int offsetRoot,
       if(fld->field_fixed == -1){
         fld->field_fixed = 0;
       }else{//0: string
-        size = strlen((char*)evD) + 1; //include end : '\0'
+        /* Hope my implementation is faster than strlen (Mathieu) */
+        char *ptr=(char*)evD;
+        size = 1;
+        while(*ptr != '\0') { size++; ptr++; }
+        //size = ptr - (char*)evD + 1; //include end : '\0'
       }
       break;
       
This page took 0.022604 seconds and 4 git commands to generate.