Enlightenment CVS committal Author : cedric Project : e17 Module : libs/eet
Dir : e17/libs/eet/src/lib Modified Files: eet_data.c Log Message: Improve speed by comparing pointer instead of calling strcmp (thanks to the dictionnary's property). =================================================================== RCS file: /cvs/e/e17/libs/eet/src/lib/eet_data.c,v retrieving revision 1.89 retrieving revision 1.90 diff -u -3 -r1.89 -r1.90 --- eet_data.c 17 Jul 2008 20:28:59 -0000 1.89 +++ eet_data.c 18 Jul 2008 11:39:38 -0000 1.90 @@ -124,6 +124,7 @@ struct _Eet_Data_Descriptor { const char *name; + const Eet_Dictionary *ed; int size; struct { void *(*mem_alloc) (size_t size); @@ -156,6 +157,7 @@ { const char *name; const char *counter_name; + const char *directory_name_ptr; Eet_Data_Descriptor *subtype; int offset; /* offset in bytes from the base element */ int count; /* number of elements for a fixed array */ @@ -919,12 +921,27 @@ if (hash < 0) hash = _eet_hash_gen(name, 6); else hash &= 0x3f; if (!edd->elements.hash.buckets[hash].element) return NULL; - if (!strcmp(edd->elements.hash.buckets[hash].element->name, name)) + /* + When we use the dictionnary as a source for chunk name, we will always + have the same pointer in name. It's a good idea to just compare pointer + instead of running strcmp on both string. + */ + if (edd->elements.hash.buckets[hash].element->directory_name_ptr == name) return edd->elements.hash.buckets[hash].element; + if (!strcmp(edd->elements.hash.buckets[hash].element->name, name)) + { + edd->elements.hash.buckets[hash].element->directory_name_ptr = name; + return edd->elements.hash.buckets[hash].element; + } bucket = edd->elements.hash.buckets[hash].next; while (bucket) { - if (!strcmp(bucket->element->name, name)) return bucket->element; + if (bucket->element->directory_name_ptr == name) return bucket->element; + if (!strcmp(bucket->element->name, name)) + { + bucket->element->directory_name_ptr = name; + return bucket->element; + } bucket = bucket->next; } return NULL; @@ -974,6 +991,7 @@ if (!edd) return NULL; edd->name = name; + edd->ed = NULL; edd->size = size; edd->func.mem_alloc = _eet_mem_alloc; edd->func.mem_free = _eet_mem_free; @@ -1003,6 +1021,7 @@ if (!edd) return NULL; edd->name = eddc->name; + edd->ed = NULL; edd->size = eddc->size; edd->func.mem_alloc = _eet_mem_alloc; edd->func.mem_free = _eet_mem_free; @@ -1038,6 +1057,7 @@ if (!edd) return NULL; edd->name = eddc->name; + edd->ed = NULL; edd->size = eddc->size; edd->func.mem_alloc = _eet_mem_alloc; edd->func.mem_free = _eet_mem_free; @@ -1093,6 +1113,7 @@ if (!edd->elements.set) return; ede = &(edd->elements.set[edd->elements.num - 1]); ede->name = name; + ede->directory_name_ptr = NULL; /* * We do a special case when we do list,hash or whatever group of simple type. @@ -2103,6 +2124,12 @@ { data = edd->func.mem_alloc(edd->size); if (!data) return NULL; + if (edd->ed != ed) + { + for (i = 0; i < edd->elements.num; i++) + edd->elements.set[i].directory_name_ptr = NULL; + edd->ed = ed; + } } _eet_freelist_ref(); _eet_freelist_str_ref(); ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs